diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..18bfe0d --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.stack-work/ +dist-newstyle/ +stack.yaml.lock +*~ +.DS_Store +*.swp +test/generated/ \ No newline at end of file diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 9b572cd..0000000 --- a/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -David Castro Pérez -Henrique Ferreiro García diff --git a/ChangeLog.md b/ChangeLog.md new file mode 100644 index 0000000..8a32d9d --- /dev/null +++ b/ChangeLog.md @@ -0,0 +1,18 @@ +# Changelog for CoreErlang + +## Unreleased changes + +- Add test cases + +## 0.1.0.0 + +- Initial release + +## 0.0.5.0 + +- Support erlang map syntax + +## 0.0.4.0 + +- Forked from amtal/CoreErlang + diff --git a/CoreErlang.cabal b/CoreErlang.cabal index 252dcf1..8975a23 100644 --- a/CoreErlang.cabal +++ b/CoreErlang.cabal @@ -1,35 +1,79 @@ -name: CoreErlang -version: 0.0.4 -copyright: 2008, David Castro Pérez, Henrique Ferreiro García -license: BSD3 -license-file: LICENSE -author: David Castro Pérez - Henrique Ferreiro García -maintainer: - Alex Kropivny -homepage: http://github.com/amtal/CoreErlang -category: Language -synopsis: Manipulating Core Erlang source code -description: - Facilities for manipulating Core Erlang source code: - an abstract syntax, parser and pretty-printer. -build-type: Simple -cabal-version: >= 1.6 +cabal-version: 1.12 +-- This file has been generated from package.yaml by hpack version 0.31.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: a0faa729ab4adcde1ae8edd4ad14800ff6b9c9f1404ea2b70e037628548d3dae + +name: CoreErlang +version: 0.0.5 +synopsis: Manipulating Core Erlang source code +description: Facilities for manipulating Core Erlang source code: an abstract syntax, parser and pretty-printer. +category: Language +homepage: https://github.com/hamler-lang/CoreErlang +bug-reports: https://github.com/hamler-lang/CoreErlang/issues +author: David Castro Pérez , Henrique Ferreiro García +maintainer: Alex Kropivny , Feng Lee +copyright: 2008, David Castro Pérez, Henrique Ferreiro García +license: BSD3 +license-file: LICENSE +build-type: Simple extra-source-files: - AUTHORS LICENSE + README.md + ChangeLog.md + +source-repository head + type: git + location: https://github.com/hamler-lang/CoreErlang library exposed-modules: - Language.CoreErlang.Parser, - Language.CoreErlang.Pretty, - Language.CoreErlang.Syntax - build-depends: - base >=4.8 && <=4.11, - pretty >=1.1 && <1.2, - parsec >=3.1 && <3.2 - other-extensions: DeriveDataTypeable + Language.CoreErlang + other-modules: + Language.CoreErlang.Parser + Language.CoreErlang.Pretty + Language.CoreErlang.Syntax + Paths_CoreErlang + hs-source-dirs: + src + default-extensions: DeriveDataTypeable LambdaCase + ghc-options: -Wall -O2 + build-depends: + base >=4.7 && <5 + , directory >= 1.3.3.0 + , parsec >=3.1 && <3.2 + , pretty >=1.1 && <1.2 + , tasty >= 1.2 + , tasty-hspec >= 1.1.5.1 + , megaparsec >= 8.0.0 + , text >= 1.2.3.1 + , prettyprinter >= 1.2.1 + , filepath>=1.4.2.1 + default-language: Haskell2010 -source-repository head - type: git - location: https://github.com/amtal/CoreErlang.git +test-suite test + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + TestParser + Paths_CoreErlang + hs-source-dirs: + test + default-extensions: DeriveDataTypeable LambdaCase + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + CoreErlang + , base >=4.7 && <5 + , directory >= 1.3.3.0 + , hspec + , parsec >=3.1 && <3.2 + , pretty >=1.1 && <1.2 + , tasty + , tasty >= 1.2 + , tasty-hspec + , tasty-hspec >= 1.1.5.1 + , megaparsec >= 8.0.0 + , prettyprinter >= 1.2.1 + , filepath >= 1.4.2.1 + default-language: Haskell2010 diff --git a/Language/CoreErlang/Parser.hs b/Language/CoreErlang/Parser.hs deleted file mode 100644 index 5568354..0000000 --- a/Language/CoreErlang/Parser.hs +++ /dev/null @@ -1,386 +0,0 @@ ------------------------------------------------------------------------------ --- | --- Module : Language.CoreErlang.Parser --- Copyright : (c) Henrique Ferreiro García 2008 --- (c) David Castro Pérez 2008 --- License : BSD-style (see the file LICENSE) --- --- Maintainer : Alex Kropivny --- Stability : experimental --- Portability : portable --- --- CoreErlang parser. --- - ------------------------------------------------------------------------------ - -module Language.CoreErlang.Parser - ( parseModule - , ParseError - ) where - -import Language.CoreErlang.Syntax - -import Control.Monad ( liftM ) -import Data.Char ( isControl, chr ) -import Numeric ( readOct ) - -import Text.ParserCombinators.Parsec -import Text.ParserCombinators.Parsec.Expr -import qualified Text.ParserCombinators.Parsec.Token as Token -import Text.ParserCombinators.Parsec.Token - ( makeTokenParser, TokenParser ) -import Text.ParserCombinators.Parsec.Language - --- Lexical definitions - -uppercase :: Parser Char -uppercase = upper - -lowercase :: Parser Char -lowercase = lower - -inputchar :: Parser Char -inputchar = noneOf "\n\r" - -control :: Parser Char -control = satisfy isControl - -namechar :: Parser Char -namechar = uppercase <|> lowercase <|> digit <|> oneOf "@_" - -escape :: Parser Char -escape = do char '\\' - s <- octal <|> ctrl <|> escapechar - return s - -octal :: Parser Char -octal = do chars <- tryOctal - let [(o, _)] = readOct chars - return (chr o) - -tryOctal :: Parser [Char] -tryOctal = choice [ try (count 3 octaldigit), - try (count 2 octaldigit), - try (count 1 octaldigit) ] - -octaldigit :: Parser Char -octaldigit = oneOf "01234567" - -ctrl :: Parser Char -ctrl = char '^' >> ctrlchar - -ctrlchar :: Parser Char -ctrlchar = satisfy (`elem` ['\x0040'..'\x005f']) - -escapechar = oneOf "bdefnrstv\"\'\\" - --- Terminals - -integer :: Parser Integer -integer = do i <- positive <|> negative <|> decimal - whiteSpace -- TODO: buff - return $ i - -positive :: Parser Integer -positive = do char '+' - p <- decimal - return p - -negative :: Parser Integer -negative = do char '-' - n <- decimal - return $ negate n - --- float :: Parser Double --- float = sign?digit+.digit+((E|e)sign?digit+)? - -atom :: Parser Atom -atom = do char '\'' --- ((inputchar except control and \ and ')|escape)* --- inputchar = noneOf "\n\r" - a <- many (noneOf "\n\r\\\'") - char '\'' - whiteSpace -- TODO: buff - return $ Atom a - -echar :: Parser Literal --- char = $((inputchar except control and space and \)|escape) -echar = do char '$' - c <- noneOf "\n\r\\ " - whiteSpace -- TODO: buff - return $ LChar c - -estring :: Parser Literal --- string = "((inputchar except control and \\ and \"")|escape)*" -estring = do char '"' - s <- many $ noneOf "\n\r\\\"" - char '"' - return $ LString s - -variable :: Parser Var --- variable = (uppercase | (_ namechar)) namechar* -variable = identifier - --- Non-terminals - -emodule :: Parser (Ann Module) -emodule = annotated amodule - -amodule :: Parser Module -amodule = do reserved "module" - name <- atom - funs <- exports - attrs <- attributes - fundefs <- many fundef - reserved "end" - return $ Module name funs attrs fundefs - -exports :: Parser [Function] -exports = brackets $ commaSep function - -attributes :: Parser [(Atom,Const)] -attributes = do reserved "attributes" - brackets (commaSep $ do a <- atom - symbol "=" - c <- constant - return (a,c)) - -constant :: Parser Const -constant = liftM CLit (try literal) <|> - liftM CTuple (tuple constant) <|> - liftM CList (elist constant) - -fundef :: Parser FunDef -fundef = do name <- annotated function - symbol "=" - body <- annotated lambda - return $ FunDef name body - -function :: Parser Function -function = do a <- atom - char '/' - i <- decimal - whiteSpace -- TODO: buff - return $ Function (a,i) - -literal :: Parser Literal -literal = try (liftM LFloat float) <|> liftM LInt integer <|> - liftM LAtom atom <|> nil <|> echar <|> estring - -nil :: Parser Literal -nil = brackets (return LNil) - -expression :: Parser Exps -expression = try (liftM Exps (annotated $ angles $ commaSep (annotated sexpression))) <|> - liftM Exp (annotated sexpression) - -sexpression :: Parser Exp -sexpression = app <|> ecatch <|> ecase <|> elet <|> - liftM Fun (try function) {- because of atom -} <|> - lambda <|> letrec <|> liftM Binary (ebinary expression) <|> - liftM List (try $ elist expression) {- because of nil -} <|> - liftM Lit literal <|> modcall <|> op <|> receive <|> - eseq <|> etry <|> liftM Tuple (tuple expression) <|> - liftM Var variable - -app :: Parser Exp -app = do reserved "apply" - e1 <- expression - eN <- parens $ commaSep expression - return $ App e1 eN - -ecatch :: Parser Exp -ecatch = do reserved "catch" - e <- expression - return $ Catch e - -ebinary :: Parser a -> Parser [BitString a] -ebinary p = do symbol "#" - bs <- braces (commaSep (bitstring p)) - symbol "#" - return bs - -bitstring :: Parser a -> Parser (BitString a) -bitstring p = do symbol "#" - e0 <- angles p - es <- parens (commaSep expression) - return $ BitString e0 es - -ecase :: Parser Exp -ecase = do reserved "case" - exp <- expression - reserved "of" - alts <- many1 (annotated clause) - reserved "end" - return $ Case exp alts - -clause :: Parser Alt -clause = do pat <- patterns - g <- guard - symbol "->" - exp <- expression - return $ Alt pat g exp - -patterns :: Parser Pats -patterns = liftM Pat pattern <|> - liftM Pats (angles $ commaSep pattern) - -pattern :: Parser Pat -pattern = liftM PAlias (try alias) {- because of variable -} <|> liftM PVar variable <|> - liftM PLit (try literal) {- because of nil -} <|> liftM PTuple (tuple pattern) <|> - liftM PList (elist pattern) <|> liftM PBinary (ebinary pattern) - -alias :: Parser Alias -alias = do v <- variable - symbol "=" - p <- pattern - return $ Alias v p - -guard :: Parser Guard -guard = do reserved "when" - e <- expression - return $ Guard e - -elet :: Parser Exp -elet = do reserved "let" - vars <- variables - symbol "=" - e1 <- expression - symbol "in" - e2 <- expression - return $ Let (vars,e1) e2 - -variables :: Parser [Var] -variables = do { v <- variable; return [v]} <|> (angles $ commaSep variable) - -lambda :: Parser Exp -lambda = do reserved "fun" - vars <- parens $ commaSep variable - symbol "->" - expr <- expression - return $ Lambda vars expr - -letrec :: Parser Exp -letrec = do reserved "letrec" - defs <- many fundef - reserved "in" - e <- expression - return $ LetRec defs e - -elist :: Parser a -> Parser (List a) -elist a = brackets $ list a - -list :: Parser a -> Parser (List a) -list elem = do elems <- commaSep1 elem - option (L elems) (do symbol "|" - t <- elem - return $ LL elems t) - -modcall :: Parser Exp -modcall = do reserved "call" - e1 <- expression - symbol ":" - e2 <- expression - eN <- parens $ commaSep expression - return $ ModCall (e1, e2) eN - -op :: Parser Exp -op = do reserved "primop" - a <- atom - e <- parens $ commaSep expression - return $ Op a e - -receive :: Parser Exp -receive = do reserved "receive" - alts <- many $ annotated clause - to <- timeout - return $ Rec alts to - -timeout :: Parser TimeOut -timeout = do reserved "after" - e1 <- expression - symbol "->" - e2 <- expression - return $ TimeOut e1 e2 - -eseq :: Parser Exp -eseq = do reserved "do" - e1 <- expression - e2 <- expression - return $ Seq e1 e2 - -etry :: Parser Exp -etry = do reserved "try" - e1 <- expression - reserved "of" - v1 <- variables - symbol "->" - e2 <- expression - reserved "catch" - v2 <- variables - symbol "->" - e3 <- expression - return $ Try e1 (v1,e1) (v2,e2) - -tuple :: Parser a -> Parser [a] -tuple elem = braces $ commaSep elem - -annotation :: Parser [Const] -annotation = do symbol "-|" - cs <- brackets $ many constant - return $ cs - -annotated :: Parser a -> Parser (Ann a) -annotated p = parens (do e <- p - cs <- annotation - return $ Ann e cs) - <|> - do e <- p - return $ Constr e - -lexer :: TokenParser () -lexer = makeTokenParser - (emptyDef { - -- commentStart = "", - -- commentEnd = "", - commentLine = "%", - -- nestedComments = True, - identStart = upper <|> char '_', - identLetter = namechar - -- opStart, - -- opLetter, - -- reservedNames, - -- reservedOpNames, - -- caseSensitive = True, - }) - -angles = Token.angles lexer -braces = Token.braces lexer -brackets = Token.brackets lexer -commaSep = Token.commaSep lexer -commaSep1 = Token.commaSep1 lexer -decimal = Token.decimal lexer -float = Token.float lexer -identifier = Token.identifier lexer -natural = Token.natural lexer -parens = Token.parens lexer -reserved = Token.reserved lexer -reservedOp = Token.reservedOp lexer -symbol = Token.symbol lexer -whiteSpace = Token.whiteSpace lexer - -runLex :: Show a => Parser a -> String -> IO () -runLex p file = do input <- readFile file - parseTest (do whiteSpace - x <- p - eof - return x) input - return () - --- | Parse of a string, which should contain a complete CoreErlang module -parseModule :: String -> Either ParseError (Ann Module) -parseModule input = parse (do whiteSpace - x <- emodule - eof - return x) "" input diff --git a/Language/CoreErlang/Pretty.hs b/Language/CoreErlang/Pretty.hs deleted file mode 100644 index f8ab94c..0000000 --- a/Language/CoreErlang/Pretty.hs +++ /dev/null @@ -1,424 +0,0 @@ ------------------------------------------------------------------------------ --- | --- Module : Language.CoreErlang.Pretty --- Copyright : (c) Henrique Ferreiro García 2008 --- (c) David Castro Pérez 2008 --- License : BSD-style (see the file LICENSE) --- --- Maintainer : Alex Kropivny --- Stability : experimental --- Portability : portable --- --- Pretty printer for CoreErlang. --- ------------------------------------------------------------------------------ - -module Language.CoreErlang.Pretty ( - -- * Pretty printing - Pretty, - prettyPrintStyleMode, prettyPrintWithMode, prettyPrint, - -- * Pretty-printing styles (from -- "Text.PrettyPrint.HughesPJ") - P.Style(..), P.style, P.Mode(..), - -- * CoreErlang formatting modes - PPMode(..), Indent, PPLayout(..), defaultMode) where - -import Language.CoreErlang.Syntax - -import qualified Text.PrettyPrint as P - -infixl 5 $$$ - -------------------------------------------------------------------------------- - --- | Varieties of layout we can use. -data PPLayout = PPDefault -- ^ classical layout - | PPNoLayout -- ^ everything on a single line - deriving Eq - -type Indent = Int - --- | Pretty-printing parameters. -data PPMode = PPMode { - altIndent :: Indent, -- ^ indentation of the alternatives - -- in a @case@ expression - caseIndent :: Indent, -- ^ indentation of the declarations - -- in a @case@ expression - fundefIndent :: Indent, -- ^ indentation of the declarations - -- in a function definition - lambdaIndent :: Indent, -- ^ indentation of the declarations - -- in a @lambda@ expression - letIndent :: Indent, -- ^ indentation of the declarations - -- in a @let@ expression - letrecIndent :: Indent, -- ^ indentation of the declarations - -- in a @letrec@ expression - onsideIndent :: Indent, -- ^ indentation added for continuation - -- lines that would otherwise be offside - layout :: PPLayout -- ^ Pretty-printing style to use - } - --- | The default mode: pretty-print using sensible defaults. -defaultMode :: PPMode -defaultMode = PPMode { - altIndent = 4, - caseIndent = 4, - fundefIndent = 4, - lambdaIndent = 4, - letIndent = 4, - letrecIndent = 4, - onsideIndent = 4, - layout = PPDefault - } - --- | Pretty printing monad -newtype DocM s a = DocM (s -> a) - -instance Functor (DocM s) where - fmap f xs = do x <- xs; return (f x) - -instance Applicative (DocM s) where - pure = return - (<*>) m1 m2 = do x1 <- m1; x2 <- m2; return (x1 x2) - -instance Monad (DocM s) where - (>>=) = thenDocM - (>>) = then_DocM - return = retDocM - -{-# INLINE thenDocM #-} -{-# INLINE then_DocM #-} -{-# INLINE retDocM #-} -{-# INLINE unDocM #-} -{-# INLINE getPPEnv #-} - -thenDocM :: DocM s a -> (a -> DocM s b) -> DocM s b -thenDocM m k = DocM $ (\s -> case unDocM m $ s of a -> unDocM (k a) $ s) - -then_DocM :: DocM s a -> DocM s b -> DocM s b -then_DocM m k = DocM $ (\s -> case unDocM m $ s of _ -> unDocM k $ s) - -retDocM :: a -> DocM s a -retDocM a = DocM (\_s -> a) - -unDocM :: DocM s a -> (s -> a) -unDocM (DocM f) = f - --- all this extra stuff, just for this one function. -getPPEnv :: DocM s s -getPPEnv = DocM id - --- | The document type produced by these pretty printers uses a 'PPMode' --- environment. -type Doc = DocM PPMode P.Doc - --- | Things that can be pretty-printed, including all the syntactic objects --- in "Language.CoreErlang.Syntax". -class Pretty a where - -- | Pretty-print something in isolation. - pretty :: a -> Doc - -- | Pretty-print something in a precedence context. - prettyPrec :: Int -> a -> Doc - pretty = prettyPrec 0 - prettyPrec _ = pretty - --- The pretty printing combinators - -empty :: Doc -empty = return P.empty - -nest :: Int -> Doc -> Doc -nest i m = m >>= return . P.nest i - --- Literals -text, ptext :: String -> Doc -text = return . P.text -ptext = return . P.text - -char :: Char -> Doc -char = return . P.char - -int :: Int -> Doc -int = return . P.int - -integer :: Integer -> Doc -integer = return . P.integer - -float :: Float -> Doc -float = return . P.float - -double :: Double -> Doc -double = return . P.double - --- Simple Combining Forms -parens, brackets, braces, quotes, doubleQuotes :: Doc -> Doc -parens d = d >>= return . P.parens -brackets d = d >>= return . P.brackets -braces d = d >>= return . P.braces -quotes d = d >>= return . P.quotes -doubleQuotes d = d >>= return . P.doubleQuotes - -parensIf :: Bool -> Doc -> Doc -parensIf True = parens -parensIf False = id - --- Constants -semi, comma, colon, space, equals :: Doc -semi = return P.semi -comma = return P.comma -colon = return P.colon -space = return P.space -equals = return P.equals - -lparen, rparen, lbrack, rbrack, lbrace, rbrace :: Doc -lparen = return P.lparen -rparen = return P.rparen -lbrack = return P.lbrack -rbrack = return P.rbrack -lbrace = return P.lbrace -rbrace = return P.rbrace - --- Combinators - -(<>),(<+>),($$),($+$) :: Doc -> Doc -> Doc -aM <> bM = do { a <- aM; b <- bM; return $ a P.<> b} -aM <+> bM = do { a <- aM; b <- bM; return $ a P.<+> b} -aM $$ bM = do { a <- aM; b <- bM; return $ a P.$$ b} -aM $+$ bM = do { a <- aM; b <- bM; return $ a P.$+$ b} - -hcat, hsep, vcat, sep, cat, fsep, fcat :: [Doc] -> Doc -hcat dl = sequence dl >>= return . P.hcat -hsep dl = sequence dl >>= return . P.hsep -vcat dl = sequence dl >>= return . P.vcat -sep dl = sequence dl >>= return . P.sep -cat dl = sequence dl >>= return . P.cat -fsep dl = sequence dl >>= return . P.fsep -fcat dl = sequence dl >>= return . P.fcat - --- Some More - -hang :: Doc -> Int -> Doc -> Doc -hang dM i rM = do { d <- dM; r <- rM; return $ P.hang d i r } - --- Yuk, had to cut-n-paste this one from Pretty.hs -punctuate :: Doc -> [Doc] -> [Doc] -punctuate _ [] = [] -punctuate p (d1:ds) = go d1 ds - where - go d [] = [d] - go d (e:es) = (d <> p) : go e es - --- | render the document with a given style and mode. -renderStyleMode :: P.Style -> PPMode -> Doc -> String -renderStyleMode ppStyle ppMode d = P.renderStyle ppStyle . unDocM d $ ppMode - --- | render the document with a given mode. -renderWithMode :: PPMode -> Doc -> String -renderWithMode = renderStyleMode P.style - --- | render the document with defaultMode -render :: Doc -> String -render = renderWithMode defaultMode - --- | pretty-print with a given style and mode. -prettyPrintStyleMode :: Pretty a => P.Style -> PPMode -> a -> String -prettyPrintStyleMode ppStyle ppMode = renderStyleMode ppStyle ppMode . pretty - --- | pretty-print with the default style and a given mode. -prettyPrintWithMode :: Pretty a => PPMode -> a -> String -prettyPrintWithMode = prettyPrintStyleMode P.style - --- | pretty-print with the default style and 'defaultMode'. -prettyPrint :: Pretty a => a -> String -prettyPrint = prettyPrintWithMode defaultMode - -fullRenderWithMode :: PPMode -> P.Mode -> Int -> Float -> - (P.TextDetails -> a -> a) -> a -> Doc -> a -fullRenderWithMode ppMode m i f fn e mD = - P.fullRender m i f fn e $ (unDocM mD) ppMode - -fullRender :: P.Mode -> Int -> Float -> (P.TextDetails -> a -> a) - -> a -> Doc -> a -fullRender = fullRenderWithMode defaultMode - -------------------------- Pretty-Print a Module -------------------- -instance Pretty Module where - pretty (Module m exports attrs fundefs) = - topLevel (ppModuleHeader m exports attrs) - (map pretty fundefs) - --------------------------- Module Header ------------------------------ -ppModuleHeader :: Atom -> [Function] -> [(Atom,Const)] -> Doc -ppModuleHeader m exports attrs = myFsep [ - text "module" <+> pretty m <+> (bracketList $ map pretty exports), - text "attributes" <+> bracketList (map ppAssign attrs)] - -instance Pretty Function where - pretty (Function (name,arity)) = - pretty name <> char '/' <> integer arity - -instance Pretty Const where - pretty (CLit l) = pretty l - pretty (CTuple l) = ppTuple l - pretty (CList l) = pretty l - -------------------------- Declarations ------------------------------ -instance Pretty FunDef where - pretty (FunDef function exp) = (pretty function <+> char '=') $$$ - ppBody fundefIndent [pretty exp] - -------------------------- Expressions ------------------------- -instance Pretty Literal where - pretty (LChar c) = char c - pretty (LString s) = text (show s) - pretty (LInt i) = integer i - pretty (LFloat f) = double f - pretty (LAtom a) = pretty a - pretty LNil = bracketList [empty] - -instance Pretty Atom where - pretty (Atom a) = char '\'' <> text a <> char '\'' - -instance Pretty Exps where - pretty (Exp e) = pretty e - pretty (Exps (Constr e)) = angleList (map pretty e) - pretty (Exps (Ann e cs)) = parens (angleList (map pretty e) - $$$ ppAnn cs) - -instance Pretty Exp where - pretty (Var v) = text v - pretty (Lit l) = pretty l - pretty (Fun f) = pretty f - pretty (App e exps) = text "apply" <+> - pretty e <> parenList (map pretty exps) - pretty (ModCall (e1,e2) exps) = sep [text "call" <+> - pretty e1 <> char ':' <> pretty e2, - parenList (map pretty exps)] - pretty (Lambda vars e) = sep [text "fun" <> parenList (map text vars) <+> text "->", - ppBody lambdaIndent [pretty e]] - pretty (Seq e1 e2) = sep [text "do", pretty e1, pretty e2] - pretty (Let (vars,e1) e2) = text "let" <+> - angleList (map text vars) <+> - char '=' <+> pretty e1 - $$$ text "in" <+> pretty e2 - pretty (LetRec fundefs e) = sep [text "letrec" <+> - ppBody letrecIndent (map pretty fundefs), - text "in", pretty e] - pretty (Case e alts) = sep [text "case", pretty e, text "of"] - $$$ ppBody caseIndent (map pretty alts) - $$$ text "end" - pretty (Tuple exps) = braceList $ map pretty exps - pretty (List l) = pretty l - pretty (Op a exps) = text "primop" <+> pretty a <> parenList (map pretty exps) - pretty (Binary bs) = char '#' <> braceList (map pretty bs) <> char '#' - pretty (Try e (vars1,exps1) (vars2,exps2)) = text "try" - $$$ ppBody caseIndent [pretty e] - $$$ text "of" <+> angleList (map text vars1) <+> text "->" - $$$ ppBody altIndent [pretty exps1] - $$$ text "catch" <+> angleList (map text vars2) <+> text "->" - $$$ ppBody altIndent [pretty exps2] - pretty (Rec alts tout) = text "receive" - $$$ ppBody caseIndent (map pretty alts) - $$$ text "after" - $$$ ppBody caseIndent [pretty tout] - pretty (Catch e) = sep [text "catch", pretty e] - -instance Pretty a => Pretty (List a) where - pretty (L l) = bracketList $ map pretty l - pretty (LL h t) = brackets . hcat $ punctuate comma (map pretty h) ++ - [char '|' <> pretty t] -instance Pretty Alt where - pretty (Alt pats guard exps) = - myFsep [pretty pats, pretty guard <+> text "->"] - $$$ ppBody altIndent [pretty exps] - -instance Pretty Pats where - pretty (Pat p) = pretty p - pretty (Pats p) = angleList (map pretty p) - -instance Pretty Pat where - pretty (PVar v) = text v - pretty (PLit l) = pretty l - pretty (PTuple p) = braceList $ map pretty p - pretty (PList l) = pretty l - pretty (PBinary bs) = char '#' <> braceList (map pretty bs) <> char '#' - pretty (PAlias a) = pretty a - -instance Pretty Alias where - pretty (Alias v p) = ppAssign (Var v,p) -- FIXME: hack! - -instance Pretty Guard where - pretty (Guard e) = text "when" <+> pretty e - -instance Pretty TimeOut where - pretty (TimeOut e1 e2) = pretty e1 <+> text "->" - $$$ ppBody altIndent [pretty e2] - -instance Pretty a => Pretty (BitString a) where - pretty (BitString e es) = text "#<" <> pretty e <> char '>' <> parenList (map pretty es) - ------------------------ Annotations ------------------------ -instance Pretty a => Pretty (Ann a) where - pretty (Constr a) = pretty a - pretty (Ann a cs) = parens (pretty a $$$ ppAnn cs) - - -------------------------- pp utils ------------------------- -angles :: Doc -> Doc -angles p = char '<' <> p <> char '>' - -angleList :: [Doc] -> Doc -angleList = angles . myFsepSimple . punctuate comma - -braceList :: [Doc] -> Doc -braceList = braces . myFsepSimple . punctuate comma - -bracketList :: [Doc] -> Doc -bracketList = brackets . myFsepSimple . punctuate comma - -parenList :: [Doc] -> Doc -parenList = parens . myFsepSimple . punctuate comma - --- | Monadic PP Combinators -- these examine the env -topLevel :: Doc -> [Doc] -> Doc -topLevel header dl = do e <- fmap layout getPPEnv - let s = case e of - PPDefault -> header $$ vcat dl - PPNoLayout -> header <+> hsep dl - s $$$ text "end" - -ppAssign :: (Pretty a,Pretty b) => (a,b) -> Doc -ppAssign (a,b) = pretty a <+> char '=' <+> pretty b - -ppTuple :: Pretty a => [a] -> Doc -ppTuple t = braceList (map pretty t) - -ppBody :: (PPMode -> Int) -> [Doc] -> Doc -ppBody f dl = do e <- fmap layout getPPEnv - i <- fmap f getPPEnv - case e of - PPDefault -> nest i . vcat $ dl - _ -> hsep dl - -($$$) :: Doc -> Doc -> Doc -a $$$ b = layoutChoice (a $$) (a <+>) b - -myFsepSimple :: [Doc] -> Doc -myFsepSimple = layoutChoice fsep hsep - --- same, except that continuation lines are indented, --- which is necessary to avoid triggering the offside rule. -myFsep :: [Doc] -> Doc -myFsep = layoutChoice fsep' hsep - where fsep' [] = empty - fsep' (d:ds) = do - e <- getPPEnv - let n = onsideIndent e - nest n (fsep (nest (-n) d:ds)) - -layoutChoice :: (a -> Doc) -> (a -> Doc) -> a -> Doc -layoutChoice a b dl = do e <- getPPEnv - if layout e == PPDefault - then a dl - else b dl - -ppAnn :: (Pretty a) => [a] -> Doc -ppAnn cs = text "-|" <+> bracketList (map pretty cs) diff --git a/Language/CoreErlang/Syntax.hs b/Language/CoreErlang/Syntax.hs deleted file mode 100644 index 295d2b8..0000000 --- a/Language/CoreErlang/Syntax.hs +++ /dev/null @@ -1,157 +0,0 @@ ------------------------------------------------------------------------------ --- | --- Module : Language.CoreErlang.Syntax --- Copyright : (c) Henrique Ferreiro García 2008 --- (c) David Castro Pérez 2008 --- License : BSD-style (see the file LICENSE) --- --- Maintainer : Alex Kropivny --- Stability : experimental --- Portability : portable --- --- A suite of datatypes describing the abstract syntax of CoreErlang 1.0.3. --- - ------------------------------------------------------------------------------ -{-# LANGUAGE DeriveDataTypeable #-} - -module Language.CoreErlang.Syntax ( - -- * Modules - Module(..), - -- * Declarations - FunDef(..), - -- * Expressions - Exp(..), Exps(..), Alt(..), Guard(..), - List(..), TimeOut(..), BitString(..), Function(..), - -- * Patterns - Pats(..), Pat(..), Alias(..), - -- * Literals - Literal(..), Const(..), Atom(..), - -- * Variables - Var, - -- * Annotations - Ann(..), - ) where - -import Data.Data - --- | This type is used to represent variables -type Var = String - --- | This type is used to represent atoms -data Atom = Atom String - deriving (Eq,Ord,Show,Data,Typeable) - --- | This type is used to represent function names -data Function = Function (Atom,Integer) - deriving (Eq,Ord,Show,Data,Typeable) - --- | A CoreErlang source module. -data Module - = Module Atom [Function] [(Atom,Const)] [FunDef] - deriving (Eq,Ord,Show,Data,Typeable) - --- | This type is used to represent constants -data Const - = CLit Literal - | CTuple [Const] - | CList (List Const) - deriving (Eq,Ord,Show,Data,Typeable) - --- | This type is used to represent lambdas -data FunDef - = FunDef (Ann Function) (Ann Exp) - deriving (Eq,Ord,Show,Data,Typeable) - --- | /literal/. --- Values of this type hold the abstract value of the literal, not the --- precise string representation used. For example, @10@, @0o12@ and @0xa@ --- have the same representation. -data Literal - = LChar Char -- ^ character literal - | LString String -- ^ string literal - | LInt Integer -- ^ integer literal - | LFloat Double -- ^ floating point literal - | LAtom Atom -- ^ atom literal - | LNil -- ^ empty list - deriving (Eq,Ord,Show,Data,Typeable) - --- | CoreErlang expressions. -data Exps - = Exp (Ann Exp) -- ^ single expression - | Exps (Ann [Ann Exp]) -- ^ list of expressions - deriving (Eq,Ord,Show,Data,Typeable) - --- | CoreErlang expression. -data Exp - = Var Var -- ^ variable - | Lit Literal -- ^ literal constant - | Fun Function -- ^ function name - | App Exps [Exps] -- ^ application - | ModCall (Exps,Exps) [Exps] -- ^ module call - | Lambda [Var] Exps -- ^ lambda expression - | Seq Exps Exps -- ^ sequencing - | Let ([Var],Exps) Exps -- ^ local declaration - | LetRec [FunDef] Exps -- ^ letrec expression - | Case Exps [Ann Alt] -- ^ @case@ /exp/ @of@ /alts/ end - | Tuple [Exps] -- ^ tuple expression - | List (List Exps) -- ^ list expression - | Binary [BitString Exps] -- ^ binary expression - | Op Atom [Exps] -- ^ operator application - | Try Exps ([Var],Exps) ([Var],Exps) -- ^ try expression - | Rec [Ann Alt] TimeOut -- ^ receive expression - | Catch Exps -- ^ catch expression - deriving (Eq,Ord,Show,Data,Typeable) - --- | A bitstring. -data BitString a - = BitString a [Exps] - deriving (Eq,Ord,Show,Data,Typeable) - --- | A list of expressions -data List a - = L [a] - | LL [a] a - deriving (Eq,Ord,Show,Data,Typeable) - --- | An /alt/ in a @case@ expression -data Alt - = Alt Pats Guard Exps - deriving (Eq,Ord,Show,Data,Typeable) - -data Pats - = Pat Pat -- ^ single pattern - | Pats [Pat] -- ^ list of patterns - deriving (Eq,Ord,Show,Data,Typeable) - --- | A pattern, to be matched against a value. -data Pat - = PVar Var -- ^ variable - | PLit Literal -- ^ literal constant - | PTuple [Pat] -- ^ tuple pattern - | PList (List Pat) -- ^ list pattern - | PBinary [BitString Pat] -- ^ list of bitstring patterns - | PAlias Alias -- ^ alias pattern - deriving (Eq,Ord,Show,Data,Typeable) - --- | An alias, used in patterns -data Alias - = Alias Var Pat - deriving (Eq,Ord,Show,Data,Typeable) - --- | A guarded alternative @when@ /exp/ @->@ /exp/. --- The first expression will be Boolean-valued. -data Guard - = Guard Exps - deriving (Eq,Ord,Show,Data,Typeable) - --- | The timeout of a receive expression -data TimeOut - = TimeOut Exps Exps - deriving (Eq,Ord,Show,Data,Typeable) - --- | An annotation for modules, variables, ... -data Ann a - = Constr a -- ^ core erlang construct - | Ann a [Const] -- ^ core erlang annotated construct - deriving (Eq,Ord,Show,Data,Typeable) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..41d0789 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +package = CoreErlang +stack_yaml = STACK_YAML="stack.yaml" +stack = $(stack_yaml) stack + +all: build + +build: + $(stack) build + +install: + $(stack) install + +ghci: + $(stack) ghci $(package):lib + +test: + $(stack) test --fast $(package) + +.PHONY : build install test diff --git a/README b/README deleted file mode 100644 index 77ddc48..0000000 --- a/README +++ /dev/null @@ -1,5 +0,0 @@ -CoreErlang is a haskell library which consists on a parser and pretty-printer for the intermediate language used by Erlang. - -The parser uses the Parsec library and the pretty-printer was modelled after the corresponding module of the haskell-src package. It also exposes a Syntax module which allows easy manipulation of terms. - -It is able to parse and pretty print all of Core Erlang. Remaining work includes customizing the pretty printer and refining the syntax interface. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ff71715 --- /dev/null +++ b/README.md @@ -0,0 +1,89 @@ +# CoreErlang + +CoreErlang is a haskell library which consists on a parser and pretty-printer for the intermediate language used by Erlang. + +The parser uses the Parsec library and the pretty-printer was modelled after the corresponding module of the haskell-src package. It also exposes a Syntax module which allows easy manipulation of terms. + +It is able to parse and pretty print all of Core Erlang. Remaining work includes customizing the pretty printer and refining the syntax interface. + +# Syntax + +*module* ::= **module** *Atom* [*fnamei1* , ... , *fnameik*] **attributes** [*attr1*, ..., *attrm*] *fundef1* ... *fundefn* **end** + +*attr* ::= *Atom* = *const* + +*fundef* ::= *fname* = *fun* + +*fname* ::= *Atom* / *Integer* + +*const* ::= *lit* | *clist* | *ctuple* | *cmap* + +*clist* ::= [*const1* | *const2*] + +*ctuple* ::= {*const1* , ..., *constn*} + +*cmap* ::= \~{*const1* => *const2* , ..., *constm* => *constn*}\~ + +*lit* ::= *Atom* | *Integer* | *Float* | *Char* | *String* | [ ] + +*fun* ::= **fun** (*var1*, ..., *varn*) -> *exprs* + +*var* ::= *VariableName* + +*exprs* ::= *expr* | <*expr1* , ..., *exprn*> + +*expr* ::= *var* | *fname* | *lit* | *fun* + +​            | [*exprs1* | *exprs2*] + +​            | {*exprs1*, ..., *exprsn*} + +​            | \~{*exprs1* => *exprs2* , ..., *exprsm* => *exprsn*}\~ + +​            | **let** *vars* = *exprs1* **in** *exprs2* + +​            | **case** *exprs* **of** *clause1* · · · *clausen* **end** + +​            | **letrec** *fname1* = *fun1* · · · *fnamen* = *funn* **in** *exprs* + +​            | **apply** *exprs0* (*exprs1*, . . ., *exprsn*) + +​            | **call** *exprs′1*:*exprs′2*(*exprs1*, . . ., *exprsn*) + +​            | **primop** *Atom*(*exprs1*, . . ., *exprsn*) + +​            | **receive** *clause1* · · · *clausen* **after** *exprs1* -> *exprs2* + +​            | **try** *exprs1* **of** <*var1*, . . .*varn*> -> *exprs2* + +​              **catch** <*varn+1*, . . .*varn+m*> -> *exprs3* + +​            | **do** *exprs1* *exprs2* + +​            | **catch** *exprs* + +*vars* ::= *var* | <*var1*, ..., *varn*> + +*clause* ::= *pats* **when** *exprs1* -> *exprs2* + +*pats* ::= *pat* | <*pat1*, ..., *patn*> + +*pat* ::= *var* | *lit* | *var* = *pat* | *plist* | *ptuple* | *pmap* + +*plist* ::= [*pat1* | *pat2*] + +*ptuple* ::= {*pat1*, ..., *patn*} + +*pmap* ::= \~{*pkey1* := *pat1*, ..., *pkeyn* := *patn*}\~ + +*pkey* ::= *var* | *lit* + +## License + +BSD3 + +## Authors + +- David Castro Pérez +- Henrique Ferreiro García + diff --git a/doc/Core Erlang 1.0.3.pdf b/doc/Core Erlang 1.0.3.pdf new file mode 100644 index 0000000..164651a Binary files /dev/null and b/doc/Core Erlang 1.0.3.pdf differ diff --git a/src/Language/CoreErlang.hs b/src/Language/CoreErlang.hs new file mode 100644 index 0000000..6b26cfa --- /dev/null +++ b/src/Language/CoreErlang.hs @@ -0,0 +1,53 @@ +----------------------------------------------------------------------------- +-- | +-- Module : Language.CoreErlang +-- Copyright : (c) Feng Lee 2020 +-- License : BSD-style (see the LICENSE file) +-- +-- Maintainer : Feng Lee +-- Stability : experimental +-- Portability : portable +-- +-- CoreErlang syntax, parser and pretty printer. +-- +----------------------------------------------------------------------------- +module Language.CoreErlang + ( module CE + , parseAndPretty + , parseFile + ) where + +import Language.CoreErlang.Parser as CE +import Language.CoreErlang.Pretty as CE +import Language.CoreErlang.Syntax as CE +import Data.Text.IO (readFile) +import Prelude hiding (readFile) +import Data.Functor ((<&>)) +import Prettyprinter.Render.Text ( hPutDoc ) +import System.IO (openFile, hClose, IOMode(..)) +import System.Directory (createDirectoryIfMissing) +import System.FilePath.Posix(takeDirectory) +-- +parseAndPretty :: FilePath -> IO () +parseAndPretty fp = + do x <- parseFile fp + let new = "generated/" ++ fp + createDirectoryIfMissing True $ takeDirectory new + h <- openFile new WriteMode + hPutDoc h (pretty x) + hClose h + +-- +-- printResult :: (Either ParseErr (Ann Module)) -> IO () +-- printResult (Left err) = print err +-- printResult (Right annMod) = putStrLn $ prettyPrint annMod + +parseFile :: FilePath -> IO (Either ParseErr (Module Text)) +parseFile fp = readFile fp <&> parseModuleA + + +-- readCoreFile :: FilePath -> IO Text +-- readCoreFile fp = do +-- h <- openFile fp ReadMode +-- hSetEncoding h utf8 +-- hGetContents h diff --git a/src/Language/CoreErlang/Parser.hs b/src/Language/CoreErlang/Parser.hs new file mode 100644 index 0000000..fd29464 --- /dev/null +++ b/src/Language/CoreErlang/Parser.hs @@ -0,0 +1,304 @@ +{-# LANGUAGE OverloadedStrings #-} +-- | +-- Module : Language.CoreErlang.Parser +-- Copyright : (c) Henrique Ferreiro García 2008 +-- (c) David Castro Pérez 2008 +-- (c) Feng Lee 2020 +-- License : BSD-style (see the LICENSE file) +-- Maintainer : Feng Lee +-- Stability : experimental +-- Portability : portable +-- +-- Parser for CoreErlang. +-- +module Language.CoreErlang.Parser (parseModuleA, Text, ParseErr) where + + +import Language.CoreErlang.Syntax +import Data.Text(Text, cons, pack, empty) +import Data.Void +import Text.Megaparsec +import qualified Text.Megaparsec as M +import Text.Megaparsec.Char +import qualified Text.Megaparsec.Char.Lexer as L + + +type Parser = Parsec Void Text + +escapes :: [Char] +escapes = "bdefnrstv\"\'\\" + +upper :: Parser Char +upper = upperChar + +lower :: Parser Char +lower = lowerChar + +-- digit :: Parser Char +-- digit = digitChar + +nameChar :: Parser Char +nameChar = digitChar + <|> upper <|> lower + <|> satisfy (=='@') + <|> satisfy (=='_') + +name :: Parser Text +name = pack <$> many nameChar + +text :: Char -> Parser Text +text c = pack <$ char c + <*> manyTill L.charLiteral (char c) + <* whitespace + -- where + -- notFormat = satisfy (`notElem` ['\r','\n','\\', c]) + +whitespace :: Parser () +whitespace = L.space space1 (L.skipLineComment "%") M.empty + +symbol :: Tokens Text -> Parser Text +symbol = L.symbol whitespace + +wrappedBy :: Parser a -> Text -> Text -> Parser a +wrappedBy p s1 s2 = between (symbol s1) (symbol s2) p + +commaSep :: Parser a -> Parser [a] +commaSep p = p `sepBy` (symbol ",") + +-------------------------------------------------------------------------------- +-- +-- escape :: Parser Char +-- escape = char '\\' *> escapeChar +-- +-- escapeChar :: Parser Char +-- escapeChar = foldr ((<|>) . satisfy . (==)) M.empty escapes + +--octal <|> ctrl <|> + +-------------------------------------------------------------------------------- + +tuple, parens, square, angle :: Parser a -> Parser [a] +tuple p = commaSep p `wrappedBy` "{" $ "}" +parens p = commaSep p `wrappedBy` "(" $ ")" +square p = commaSep p `wrappedBy` "[" $ "]" +angle p = commaSep p `wrappedBy` "<" $ ">" + + +-- listAtom :: Parser [Atom] +-- listAtom = (:) <$ symbol "[" +-- <*> atom +-- <*> (symbol "]" *> pure [] +-- <|> symbol "|" *> listAtom <* symbol "]") +-- <* whitespace + +list :: Parser a -> Parser (List a ann) +list p = symbol "[" + *> (p >>= \x -> option (L x) + (LL x <$ symbol "|" <*> p) ) + <* symbol "]" + +-- identifier :: Parser Text +-- identifier = cons <$> (upper <|> char '_') +-- <*> name +-- <* whitespace + +atom :: Parser (Text -> Atom Text) +atom = Atom <$> text '\'' + +charP :: Parser Char +charP = char '$' *> L.charLiteral + +stringP :: Parser Text +stringP = text '\"' + +integer :: Parser Integer +integer = L.signed space L.decimal + +float :: Parser Double +float = L.signed space L.float + +keyV :: Parser k -> Parser v -> Parser (Text -> KeyV k v Text) +keyV k v = try (Insert <$> k <* symbol "=>" <*> v <* whitespace) + <|> Update <$> k <* symbol ":=" <*> v <* whitespace + +keyV' :: Parser a -> Parser (a, a) +keyV' p = (,) <$> p <* symbol "=>" <*> p <* whitespace + +mapC :: Parser a -> Parser [a] +mapC p = commaSep p `wrappedBy` "~{" $ "}~" + +mapE :: Parser kv -> Parser a -> Parser (Map kv a ann) +mapE kv p = try (Map <$> mapC kv) + <|> ((UMap <$> commaSep kv + <* symbol "|" <*> p) + `wrappedBy` "~{" $ "}~") + +-- binary :: Parser a -> Parser [Bitstring a] +-- binary p = (commaSep (bitstring p)) `wrappedBy` "#{" $ "}#" + +binary :: Parser a -> Parser (Binary a Text) +binary p = commaSep (bitstringA p) `wrappedBy` "#{" $ "}#" + +bitstring :: Parser a -> Parser (Text -> Bitstring a Text) +bitstring p = Bitstring <$> (p `wrappedBy` "#<" $ ">") + <* symbol "(" + <*> p <* symbol "," + <*> p <* symbol "," + <*> p <* symbol "," + <*> p + <* symbol ")" + +attr :: Parser (Atom Text, Const Text) +attr = (,) <$> atomA <*> (symbol "=" *> constA) + +variables :: Parser [Var Text] +variables = angle variableA + +-------------------------------------------------------------------------------- + +moduleP :: Parser (Text -> Module Text) +moduleP = Module <$ symbol "module" + <*> atomA + <*> square funnameA + <*> attrsA + <*> many fundef + <* symbol "end" + +funname :: Parser (Text -> FunName Text) +funname = FunName <$> atomA <* char '/' <*> integer <* whitespace + +attrs :: Parser (Text -> Attrs Text) +attrs = Attrs <$ symbol "attributes" + <*> square attr + +constP :: Parser (Text -> Const Text) +constP = (CTuple <$> tuple constA + <|> try (CLit <$> literalA) + <|> CList <$> list constA + <|> CMap <$> mapC (keyV' constA) + <|> CBinary <$> binary constA) + <* whitespace + +literal :: Parser (Text -> Literal Text) +literal = (LChar <$> charP + <|> LString <$> stringP + <|> try (LFloat <$> float) + <|> LInt <$> integer + <|> LAtom <$> atomA + <|> LNil <$ symbol "[" <* symbol "]") + <* whitespace + +fun :: Parser (Text -> Fun Text) +fun = try (Fun + <$ symbol "fun" + <*> parens variableA + <* symbol "->" + <*> exprsA) + <|> ExtFun <$ symbol "fun" <*> atomA <* symbol ":" <*> funnameA + +fundef :: Parser (FunDef Text) +fundef = FunDef <$> funnameA + <* symbol "=" + <*> funA + +variable :: Parser (Text -> Var Text) +variable = Var <$> (cons <$> (char '_' <|> upperChar) + <*> name) + <* whitespace + +exprs :: Parser (Text -> Exprs Text) +exprs = Exprs <$> angle (exprA) + <|> Expr <$> exprA + +expr :: Parser (Text -> Expr Text) +expr = EVar <$> variableA + <|> EFunN <$> try funnameA + <|> ELit <$> try literalA + <|> EFun <$> funA + <|> EList <$> list exprA + <|> ETuple <$> tuple exprsA + <|> EMap <$> mapE (keyVA exprsA exprsA) exprsA + <|> EBinary <$> binary exprsA + <|> ELetRec <$ symbol "letrec" <*> many fundef <* symbol "in" <*> exprsA + <|> ELet <$ symbol "let" <*> variables <* symbol "=" <*> exprsA <* symbol "in" <*> exprsA + <|> ECase <$ symbol "case" <*> exprsA <* symbol "of" <*> some clauseA <* symbol "end" + <|> EApp <$ symbol "apply" <*> exprsA <*> parens exprsA + <|> EModCall <$ symbol "call" <*> exprsA <* symbol ":" <*> exprsA <*> parens exprsA + <|> EPrimOp <$ symbol "primop" <*> atomA <*> parens exprsA + <|> EReceive <$ symbol "receive" <*> many clauseA <* symbol "after" <*> exprsA <* symbol "->" <*> exprsA + <|> ETry <$ symbol "try" <*> exprsA <* symbol "of" <*> variables <* symbol "->" <*> exprsA + <* symbol "catch" <*> variables <* symbol "->" <*> exprsA + <|> EDo <$ symbol "do" <*> exprsA <*> exprsA + <|> ECatch <$ symbol "catch" <*> exprsA + +clause :: Parser (Text -> Clause Text) +clause = Clause <$> (angle patA + <|> (:[]) <$> patA) + <* symbol "when" <*> exprsA <* symbol "->" <*> exprsA + +pat :: Parser (Text -> Pat Text) +pat = try (PAlias <$> variableA <* symbol "=" <*> patA) + <|> try (PLiteral <$> literalA) + <|> PList <$> list patA + <|> PTuple <$> tuple patA + <|> PBinary <$> binary patA + <|> PMap <$> mapE (keyVA patA patA) patA + <|> PVar <$> variableA + +-------------------------------------------------------------------------------- +moduleA :: Parser (Module Text) +moduleA = annotation moduleP + +funnameA :: Parser (FunName Text) +funnameA = annotation funname + +attrsA :: Parser (Attrs Text) +attrsA = annotation attrs + +constA :: Parser (Const Text) +constA = annotation constP + +literalA :: Parser (Literal Text) +literalA = annotation literal + +funA :: Parser (Fun Text) +funA = annotation fun + +-- fundefA :: Parser (FunDef Text) +-- fundefA = annotation fundef + +variableA :: Parser (Var Text) +variableA = annotation variable + +exprsA :: Parser (Exprs Text) +exprsA = annotation exprs + +exprA :: Parser (Expr Text) +exprA = annotation expr + +clauseA :: Parser (Clause Text) +clauseA = annotation clause + +patA :: Parser (Pat Text) +patA = annotation pat + +atomA :: Parser (Atom Text) +atomA = annotation atom + +bitstringA :: Parser a -> Parser (Bitstring a Text) +bitstringA = annotation . bitstring + +keyVA :: Parser k -> Parser v -> Parser (KeyV k v Text) +keyVA = (annotation .) . keyV +-------------------------------------------------------------------------------- + +annotation :: Parser (Text -> a) -> Parser a +annotation p = (try ((p <* symbol "-|" <*> takeWhileP (Just "annotation") (/= ')') ) `wrappedBy` "(" $ ")") + <|> p <*> pure Data.Text.empty) <* whitespace + +-------------------------------------------------------------------------------- + +type ParseErr = ParseErrorBundle Text Void + +parseModuleA :: Text -> Either ParseErr (Module Text) +parseModuleA = parse moduleA "" diff --git a/src/Language/CoreErlang/Pretty.hs b/src/Language/CoreErlang/Pretty.hs new file mode 100644 index 0000000..6237187 --- /dev/null +++ b/src/Language/CoreErlang/Pretty.hs @@ -0,0 +1,156 @@ +{-# LANGUAGE OverloadedStrings, FlexibleInstances #-} +{-# OPTIONS_GHC -Wno-orphans #-} + +-- | +-- Module : Language.CoreErlang.Parser +-- Copyright : (c) Henrique Ferreiro García 2008 +-- (c) David Castro Pérez 2008 +-- (c) Feng Lee 2020 +-- License : BSD-style (see the LICENSE file) +-- Maintainer : Feng Lee +-- Stability : experimental +-- Portability : portable +-- +-- Parser for CoreErlang. +-- +module Language.CoreErlang.Pretty (Pretty(..), prettyText) where + +import Data.Text (unpack, replace, Text) +import Data.Char as C +import Language.CoreErlang.Syntax +import Prettyprinter +import Prettyprinter.Render.Text +import Text.Megaparsec + +commaSep :: Pretty a => [a] -> Doc ann +commaSep xs = concatWith (surround ",") (map pretty xs) + +hcommaSep :: Pretty a => [a] -> Doc ann +hcommaSep xs = concatWith (surround ("," <> hardline)) (map pretty xs) + +tuplePretty :: Pretty a => [a] -> Doc ann +tuplePretty = braces . commaSep + +binaryPretty :: Pretty a => [a] -> Doc ann +binaryPretty xs = enclose "#{" "}#" (commaSep xs) + +varsPretty :: Pretty a => [Var a] -> Doc ann +varsPretty xs = angles (commaSep xs) + + +instance {-# OVERLAPPING #-} Pretty a => Pretty (Atom a, Const a) where + pretty (x, y) = nest 4 $ pretty x <+> "=" <> hardline <+> pretty y +-- +instance (VisualStream s, TraversableStream s, Stream s, ShowErrorComponent e, Pretty a) => Pretty (Either (ParseErrorBundle s e) a) where + pretty (Right x) = pretty x + pretty (Left r) = error ("parseFail" ++ errorBundlePretty r) + +instance Pretty ann => Pretty (Atom ann) where + pretty (Atom x ann) = prettyAnn ann . squotes . pretty . replace "'" "\\'" . replace "\\" "\\\\" $ x + +instance (Pretty a, Pretty ann) => Pretty (List a ann) where + pretty (L x) = brackets $ pretty x + pretty (LL x y) = brackets $ pretty x <> "|" <> pretty y + +instance (Pretty kv, Pretty a, Pretty ann) => Pretty (Map kv a ann) where + pretty (Map kvs) = enclose "~{" "}~" (commaSep kvs) + pretty (UMap kvs x) = enclose "~{" "}~" (commaSep kvs <> "|" <> pretty x) + +instance (Pretty k, Pretty v, Pretty ann) => Pretty (KeyV k v ann) where + pretty (Insert x y ann) = prettyAnn ann $ pretty x <> "=>" <> pretty y + pretty (Update x y ann) = prettyAnn ann $ pretty x <> ":=" <> pretty y + +instance (Pretty a, Pretty ann) => Pretty (Bitstring a ann) where + pretty (Bitstring x y z m n ann) = prettyAnn ann $ "#" <> angles (pretty x) <> parens (commaSep [y,z,m,n]) + +instance Pretty ann => Pretty (FunDef ann) where + pretty (FunDef funname fun) = nest 4 $ pretty funname <+> "=" <+> pretty fun + +-------------------------------------------------------------------------------- + +instance Pretty a => Pretty (Module a) where + pretty (Module atom funnames attrs fundefs ann) + = prettyAnn ann $ + nest 4 ("module" <+> pretty atom + <> (align . list . map pretty) funnames <> hardline + <> (align "attributes" <+> pretty attrs)) <> hardline + <> vsep (pretty <$> fundefs) <+> "end" + +instance Pretty a => Pretty (FunName a) where + pretty (FunName atom n ann) = prettyAnn ann $ pretty atom <> "/" <> pretty n + +instance Pretty a => Pretty (Attrs a) where + pretty (Attrs xs ann) = prettyAnn ann $ brackets (hcommaSep xs) + +instance Pretty a => Pretty (Const a) where + pretty (CLit x ann) = prettyAnn ann $ pretty x + pretty (CTuple consts ann) = prettyAnn ann $ tuplePretty consts + pretty (CList list_ ann) = prettyAnn ann $ pretty list_ + pretty (CMap kvs ann) = prettyAnn ann $ enclose "~{" "}~" (commaSep kvs) + pretty (CBinary bstrings ann) = prettyAnn ann $ binaryPretty bstrings + +instance Pretty a => Pretty (Literal a) where + pretty (LChar x ann) = prettyAnn ann $ (pretty . toInteger . C.ord $ x) + pretty (LString x ann) = prettyAnn ann $ brackets $ commaSep $ (fmap (toInteger . C.ord)) $ unpack x + pretty (LInt x ann) = prettyAnn ann $ pretty x + pretty (LFloat x ann) = prettyAnn ann $ pretty x + pretty (LAtom x ann) = prettyAnn ann $ pretty x + pretty (LNil ann) = prettyAnn ann $ "[]" + +instance Pretty a => Pretty (Fun a) where + pretty (Fun vars x ann) = prettyAnn ann $ "fun" <+> parens (commaSep vars) <+> "->" <> hardline <> pretty x + pretty (ExtFun atom funname ann) = prettyAnn ann $ "fun" <+> pretty atom <> ":" <> pretty funname + +instance Pretty a => Pretty (Var a) where + pretty (Var x ann) = prettyAnn ann $ pretty x + +instance Pretty a => Pretty (Exprs a) where + pretty (Expr x ann) = prettyAnn ann $ pretty x + pretty (Exprs xs ann) = prettyAnn ann $ angles $ commaSep xs + +instance Pretty a => Pretty (Expr a) where + pretty (EVar var ann) = prettyAnn ann $ pretty var + pretty (EFunN funname ann) = prettyAnn ann $ pretty funname + pretty (ELit literal ann) = prettyAnn ann $ pretty literal + pretty (EFun fun ann) = prettyAnn ann $ pretty fun + pretty (EList list_ ann) = prettyAnn ann $ pretty list_ + pretty (ETuple xs ann) = prettyAnn ann $ tuplePretty xs + pretty (EMap x ann) = prettyAnn ann $ pretty x + pretty (EBinary bstrings ann) = prettyAnn ann $ binaryPretty bstrings + + pretty (ELetRec fundefs x ann) = prettyAnn ann $ "letrec" <+> hsep (pretty <$> fundefs) <+> "in" <+> pretty x + pretty (ELet vars x y ann) = prettyAnn ann $ "let" <+> varsPretty vars <+> "=" <> hardline <> pretty x <+> "in" <+> pretty y + pretty (ECase x clauses ann) = prettyAnn ann $ "case" <+> pretty x <+> "of" <> hardline <> vsep (pretty <$> clauses) <+> "end" + pretty (EApp x y ann) = prettyAnn ann $ "apply" <+> pretty x <> hardline <> parens (commaSep y) + pretty (EModCall x y xs ann) = prettyAnn ann $ "call" <+> pretty x <> ":" <> pretty y <> hardline <> parens (commaSep xs) + pretty (EPrimOp x xs ann) = prettyAnn ann $ "primop" <+> pretty x <+> parens (commaSep xs) + pretty (EReceive clauses x y ann) = prettyAnn ann $ "receive" <+> vsep (pretty <$> clauses) <+> "after" <+> pretty x <+> "->" <+> pretty y + pretty (ETry x vs y ws z ann) = prettyAnn ann $ "try" <+> pretty x <+> "of" <+> (angles $ hsep (map pretty vs)) <+> "->" <+> pretty y + <+> "catch" <+> varsPretty ws <+> "->" <+> pretty z + pretty (EDo x y ann) = prettyAnn ann $ "do" <+> pretty x <+> pretty y + pretty (ECatch x ann) = prettyAnn ann $ "catch" <+> pretty x + +instance Pretty a => Pretty (Clause a) where + pretty (Clause pats x y ann) = prettyAnn ann $ angles (commaSep pats) <+> "when" <+> pretty x <+> "->" <> hardline <> pretty y + +instance Pretty a => Pretty (Pat a) where + pretty (PVar var ann) = prettyAnn ann $ pretty var + pretty (PLiteral lit ann) = prettyAnn ann $ pretty lit + pretty (PList list_ ann) = prettyAnn ann $ pretty list_ + pretty (PTuple pats ann) = prettyAnn ann $ tuplePretty pats + pretty (PBinary bstrings ann) = prettyAnn ann $ binaryPretty bstrings + pretty (PMap m ann) = prettyAnn ann $ pretty m + pretty (PAlias var pat ann) = prettyAnn ann $ pretty var <+> "=" <+> pretty pat + +-------------------------------------------------------------------------------- +prettyAnn :: Pretty a => a -> Doc ann -> Doc ann +prettyAnn y doc + | show y' == "" = nest 2 doc + | otherwise = nest 1 $ parens $ doc <> hardline <> "-|" <> y' + where + y' = pretty y + +prettyText :: Pretty a => a -> Text +prettyText x = renderStrict (layoutSmart defaultLayoutOptions (pretty x)) +-------------------- +--simple test diff --git a/src/Language/CoreErlang/Syntax.hs b/src/Language/CoreErlang/Syntax.hs new file mode 100644 index 0000000..8ab01cd --- /dev/null +++ b/src/Language/CoreErlang/Syntax.hs @@ -0,0 +1,149 @@ +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE DeriveDataTypeable #-} +module Language.CoreErlang.Syntax where +import Data.Text(Text) +import Data.Data +import Prelude + +-------------------------------------------------------------------------------- +data Atom ann = Atom Text ann + deriving (Eq, Ord, Show, Data, Typeable) + +data KeyV k v ann = Insert k v ann + | Update k v ann + deriving (Eq, Ord, Show, Data, Typeable) + +data Bitstring a ann = Bitstring a a a a a ann + deriving (Eq, Ord, Show, Data, Typeable) + +data List a ann = L a + | LL a a + deriving (Eq, Ord, Show, Data, Typeable) + +data Map kv a ann = Map [kv] + | UMap [kv] a + deriving (Eq, Ord, Show, Data, Typeable) + +type Binary a ann = [Bitstring a ann] + +data FunDef ann = FunDef (FunName ann) (Fun ann) + deriving (Eq, Ord, Show, Data, Typeable) + +-------------------------------------------------------------------------------- + +data Module a = Module (Atom a) [FunName a] (Attrs a) [FunDef a] a + deriving (Eq, Ord, Show, Data, Typeable) + +data FunName a = FunName (Atom a) Integer a + deriving (Eq, Ord, Show, Data, Typeable) + +data Attrs a = Attrs [(Atom a, Const a)] a + deriving (Eq, Ord, Show, Data, Typeable) + + +data Const a = CLit (Literal a) a + | CTuple [Const a] a + | CList (List (Const a) a) a + | CMap [(Const a, Const a)] a + | CBinary [Bitstring (Const a) a] a + deriving (Eq, Ord, Show, Data, Typeable) + +data Literal a = LChar Char a -- ^ character literal + | LString Text a -- ^ string literal + | LInt Integer a -- ^ integer literal + | LFloat Double a -- ^ floating point literal + | LAtom (Atom a) a -- ^ atom literal + | LNil a -- ^ empty list + deriving (Eq, Ord, Show, Data, Typeable) + +data Fun a = Fun [Var a] (Exprs a) a + | ExtFun (Atom a) (FunName a) a + deriving (Eq, Ord, Show, Data, Typeable) + +data Var a = Var Text a + deriving (Eq, Ord, Show, Data, Typeable) + +data Exprs a = Expr (Expr a) a + | Exprs [Expr a] a + deriving (Eq, Ord, Show, Data, Typeable) + +data Expr a = EVar (Var a) a + | EFunN (FunName a) a + | ELit (Literal a) a + | EFun (Fun a) a + | EList (List (Expr a) a) a + | ETuple [Exprs a] a + | EMap (Map (KeyV (Exprs a) (Exprs a) a) (Exprs a) a) a + | EBinary [Bitstring (Exprs a) a] a + + | ELet [Var a] (Exprs a) (Exprs a) a + | ECase (Exprs a) [Clause a] a + | ELetRec [FunDef a] (Exprs a) a + | EApp (Exprs a) [Exprs a] a + | EModCall (Exprs a) (Exprs a) [Exprs a] a + | EPrimOp (Atom a) [Exprs a] a + | EReceive [Clause a] (Exprs a) (Exprs a) a + | ETry (Exprs a) [Var a] (Exprs a) [Var a] (Exprs a) a + | EDo (Exprs a) (Exprs a) a + | ECatch (Exprs a) a + deriving (Eq, Ord, Show, Data, Typeable) + +data Clause a = Clause [Pat a] (Exprs a) (Exprs a) a + deriving (Eq, Ord, Show, Data, Typeable) + +data Pat a = PVar (Var a) a + | PLiteral (Literal a) a + | PList (List (Pat a) a) a + | PTuple [Pat a] a + | PBinary [Bitstring (Pat a) a] a + | PMap (Map (KeyV (Pat a) (Pat a) a) (Pat a) a) a + | PAlias (Var a) (Pat a) a + deriving (Eq, Ord, Show, Data, Typeable) + +------------------------------------------------------------------------------ + +class Ann m a where + annText :: a -> (a -> m a) -> m a + +instance Ann Atom Text where + annText a f = f a + +instance Ann (KeyV k v) Text where + annText a f = f a + +instance Ann (Bitstring a) Text where + annText a f = f a + +instance Ann Module Text where + annText a f = f a + +instance Ann FunName Text where + annText a f = f a + +instance Ann Attrs Text where + annText a f = f a + +instance Ann Const Text where + annText a f = f a + +instance Ann Literal Text where + annText a f = f a + +instance Ann Fun Text where + annText a f = f a + +instance Ann Var Text where + annText a f = f a + +instance Ann Exprs Text where + annText a f = f a + +instance Ann Expr Text where + annText a f = f a + +instance Ann Clause Text where + annText a f = f a + +instance Ann Pat Text where + annText a f = f a + diff --git a/test/Spec.hs b/test/Spec.hs new file mode 100644 index 0000000..70486c9 --- /dev/null +++ b/test/Spec.hs @@ -0,0 +1,12 @@ +module Main (main) where + +import Prelude +import Test.Tasty +import Test.Tasty.Hspec + +import qualified TestParser + +main :: IO () +main = TestParser.main + -- parserTests <- TestParser.main + -- defaultMain $ testGroup "Tests" [ parserTests ] diff --git a/test/TestParser.hs b/test/TestParser.hs new file mode 100644 index 0000000..2a42396 --- /dev/null +++ b/test/TestParser.hs @@ -0,0 +1,88 @@ +module TestParser where + +import Control.Monad +import Language.CoreErlang +import System.Directory +import System.FilePath.Posix(takeDirectory) +import Test.Tasty +import Test.Tasty.Hspec +import Test.Hspec +import Text.Megaparsec (errorBundlePretty) +import System.IO (openFile, hClose, IOMode(..)) +import Prettyprinter.Render.Text (renderIO) +import Prettyprinter (layoutSmart, defaultLayoutOptions) + +main :: IO () +main = do + fps <- getCoreFiles "./test/data/jsx" + mapM_ generatePrettyCore fps + spec <- testSpec "ParseThenPretty" specCompare + defaultMain $ testGroup "Tests" [] + + +spec :: Spec +spec = do + fps <- runIO $ getCoreFiles "./test" + forM_ fps testParser +-- +specPretty :: Spec +specPretty = do + fps <- runIO $ getCoreFiles "./test/generated" + forM_ fps testPretty + +specCompare :: Spec +specCompare = do + fps <- runIO $ getCoreFiles "./test/data" + fps' <- runIO $ getCoreFiles "./test/generated" + forM_ (zip fps fps') testParseThenPretty + +testParseThenPretty :: (FilePath, FilePath) -> Spec +testParseThenPretty (f, f') = do + specify (f <> f') $ do + r <- parseFile f + r' <- parseFile f' + if r == r' then return () else expectationFailure "testFail" + +moduleName (Module name _ _ _ _) = name + +testParser :: FilePath -> Spec +testParser f = do + specify f $ do + r <- parseFile f + case r of + Left r -> expectationFailure (errorBundlePretty r) + Right annMod -> return () + +testPretty :: FilePath -> Spec +testPretty f = do + specify f $ do + r <- parseFile f + case r of + Left r -> expectationFailure (errorBundlePretty r) + Right annMod -> return () + +generatePrettyCore :: FilePath -> IO () +generatePrettyCore fp = + do x <- parseFile fp + let new = "./test/generated/" ++ drop 6 fp + createDirectoryIfMissing True $ takeDirectory new + h <- openFile new WriteMode + renderIO h (layoutSmart defaultLayoutOptions (pretty x)) + hClose h + + +isCoreFile :: String -> Bool +isCoreFile fname = (== "eroc") $ take 4 $ reverse fname + +getCoreFiles :: FilePath -> IO [FilePath] +getCoreFiles basePath = do + list <- listDirectory basePath + r <- forM list $ \filePath -> do + let tp = basePath ++ "/" ++ filePath + res <- doesDirectoryExist tp + if res + then getCoreFiles tp + else if isCoreFile filePath + then return [tp] + else return [] + return $ concat r diff --git a/test/data/Hello.core b/test/data/Hello.core new file mode 100644 index 0000000..5f9d9bc --- /dev/null +++ b/test/data/Hello.core @@ -0,0 +1,32 @@ +module 'Hello' ['add'/2, + 'id'/1, + 'module_info'/0, + 'module_info'/1, + 'sub'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[72|[101|[108|[108|[111|[46|[101|[114|[108]]]]]]]]],1}]] +'id'/1 = + %% Line 5 + fun (_0) -> + _0 +'add'/2 = + %% Line 7 + fun (_0,_1) -> + call 'erlang':'+' + (_0, _1) +'sub'/2 = + %% Line 9 + fun (_0,_1) -> + call 'erlang':'-' + (_0, _1) +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('Hello') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('Hello', _0) +end \ No newline at end of file diff --git a/test/data/Hello.erl b/test/data/Hello.erl new file mode 100644 index 0000000..c502d21 --- /dev/null +++ b/test/data/Hello.erl @@ -0,0 +1,9 @@ +-module('Hello'). + +-export([id/1, add/2, sub/2]). + +id(X) -> X. + +add(X, Y) -> X + Y. + +sub(X, Y) -> X - Y. diff --git a/test/data/Map.core b/test/data/Map.core new file mode 100644 index 0000000..3bb3466 --- /dev/null +++ b/test/data/Map.core @@ -0,0 +1,29 @@ +module 'Map' ['f'/0, + 'module_info'/0, + 'module_info'/1] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[77|[97|[112|[46|[101|[114|[108]]]]]]],1}]] +'f'/0 = + %% Line 5 + fun () -> + %% Line 6 + case ~{'a'=>1,'b'=>2}~ of + <~{'a':=A,'b':=B}~> when 'true' -> + %% Line 7 + {A,B} + ( <_0> when 'true' -> + primop 'match_fail' + ({'badmatch',_0}) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('Map') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('Map', _0) +end \ No newline at end of file diff --git a/test/data/Map.erl b/test/data/Map.erl new file mode 100644 index 0000000..0df12e7 --- /dev/null +++ b/test/data/Map.erl @@ -0,0 +1,7 @@ +-module('Map'). + +-export([f/0]). + +f() -> + #{a := A, b := B} = #{a => 1, b => 2}, + {A, B}. diff --git a/test/data/README b/test/data/README new file mode 100644 index 0000000..d7fb724 --- /dev/null +++ b/test/data/README @@ -0,0 +1 @@ +otp-OTP-23.0-rc1 libs diff --git a/test/data/jsx/jsx.core b/test/data/jsx/jsx.core new file mode 100644 index 0000000..28acfb4 --- /dev/null +++ b/test/data/jsx/jsx.core @@ -0,0 +1,274 @@ +module 'jsx' ['consult'/1, + 'consult'/2, + 'decode'/1, + 'decode'/2, + 'decoder'/3, + 'encode'/1, + 'encode'/2, + 'encoder'/3, + 'format'/1, + 'format'/2, + 'is_json'/1, + 'is_json'/2, + 'is_term'/1, + 'is_term'/2, + 'maps_support'/0, + 'minify'/1, + 'module_info'/0, + 'module_info'/1, + 'parser'/3, + 'prettify'/1, + 'resume'/3] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[46|[101|[114|[108]]]]]]],1}], + %% Line 34 + 'export_type' = + %% Line 34 + [{'json_term',0}|[{'json_text',0}|[{'token',0}]]], + %% Line 35 + 'export_type' = + %% Line 35 + [{'encoder',0}|[{'decoder',0}|[{'parser',0}|[{'internal_state',0}]]]], + %% Line 36 + 'export_type' = + %% Line 36 + [{'config',0}], + %% Line 47 + 'type' = + %% Line 47 + [{'json_term',{'type',47,'union',[{'type',47,'list',[{'type',47,'tuple',[{'type',47,'union',[{'type',47,'binary',[]}|[{'type',47,'atom',[]}]]}|[{'user_type',47,'json_term',[]}]]}]}|[{'type',47,'nonempty_list',[{'type',47,'tuple',[]}]}|[{'type',48,'list',[{'user_type',48,'json_term',[]}]}|[{'type',48,'nil',[]}|[{'atom',49,'true'}|[{'atom',49,'false'}|[{'atom',49,'null'}|[{'type',50,'integer',[]}|[{'type',50,'float',[]}|[{'type',51,'binary',[]}|[{'type',51,'atom',[]}|[{'remote_type',52,[{'atom',52,'calendar'}|[{'atom',52,'datetime'}|[[]]]]}]]]]]]]]]]]]},[]}], + %% Line 65 + 'type' = + %% Line 65 + [{'json_text',{'type',65,'binary',[]},[]}], + %% Line 67 + 'type' = + %% Line 67 + [{'config',{'remote_type',67,[{'atom',67,'jsx_config'}|[{'atom',67,'config'}|[[]]]]},[]}], + %% Line 69 + 'spec' = + %% Line 69 + [{{'encode',1},[{'type',69,'fun',[{'type',69,'product',[{'ann_type',69,[{'var',69,'Source'}|[{'user_type',69,'json_term',[]}]]}]}|[{'user_type',69,'json_text',[]}]]}]}], + %% Line 73 + 'spec' = + %% Line 73 + [{{'encode',2},[{'type',73,'fun',[{'type',73,'product',[{'ann_type',73,[{'var',73,'Source'}|[{'user_type',73,'json_term',[]}]]}|[{'ann_type',73,[{'var',73,'Config'}|[{'remote_type',73,[{'atom',73,'jsx_to_json'}|[{'atom',73,'config'}|[[]]]]}]]}]]}|[{'type',73,'union',[{'user_type',73,'json_text',[]}|[{'type',73,'tuple',[{'atom',73,'incomplete'}|[{'user_type',73,'encoder',[]}]]}]]}]]}]}], + %% Line 78 + 'spec' = + %% Line 78 + [{{'decode',1},[{'type',78,'fun',[{'type',78,'product',[{'ann_type',78,[{'var',78,'Source'}|[{'user_type',78,'json_text',[]}]]}]}|[{'user_type',78,'json_term',[]}]]}]}], + %% Line 82 + 'spec' = + %% Line 82 + [{{'decode',2},[{'type',82,'fun',[{'type',82,'product',[{'ann_type',82,[{'var',82,'Source'}|[{'user_type',82,'json_text',[]}]]}|[{'ann_type',82,[{'var',82,'Config'}|[{'remote_type',82,[{'atom',82,'jsx_to_term'}|[{'atom',82,'config'}|[[]]]]}]]}]]}|[{'type',82,'union',[{'user_type',82,'json_term',[]}|[{'type',82,'tuple',[{'atom',82,'incomplete'}|[{'user_type',82,'decoder',[]}]]}]]}]]}]}], + %% Line 87 + 'spec' = + %% Line 87 + [{{'format',1},[{'type',87,'fun',[{'type',87,'product',[{'ann_type',87,[{'var',87,'Source'}|[{'user_type',87,'json_text',[]}]]}]}|[{'user_type',87,'json_text',[]}]]}]}], + %% Line 91 + 'spec' = + %% Line 91 + [{{'format',2},[{'type',91,'fun',[{'type',91,'product',[{'ann_type',91,[{'var',91,'Source'}|[{'user_type',91,'json_text',[]}]]}|[{'ann_type',91,[{'var',91,'Config'}|[{'remote_type',91,[{'atom',91,'jsx_to_json'}|[{'atom',91,'config'}|[[]]]]}]]}]]}|[{'type',91,'union',[{'user_type',91,'json_text',[]}|[{'type',91,'tuple',[{'atom',91,'incomplete'}|[{'user_type',91,'decoder',[]}]]}]]}]]}]}], + %% Line 96 + 'spec' = + %% Line 96 + [{{'minify',1},[{'type',96,'fun',[{'type',96,'product',[{'ann_type',96,[{'var',96,'Source'}|[{'user_type',96,'json_text',[]}]]}]}|[{'user_type',96,'json_text',[]}]]}]}], + %% Line 101 + 'spec' = + %% Line 101 + [{{'prettify',1},[{'type',101,'fun',[{'type',101,'product',[{'ann_type',101,[{'var',101,'Source'}|[{'user_type',101,'json_text',[]}]]}]}|[{'user_type',101,'json_text',[]}]]}]}], + %% Line 106 + 'spec' = + %% Line 106 + [{{'is_json',1},[{'type',106,'fun',[{'type',106,'product',[{'ann_type',106,[{'var',106,'Source'}|[{'type',106,'any',[]}]]}]}|[{'type',106,'boolean',[]}]]}]}], + %% Line 110 + 'spec' = + %% Line 110 + [{{'is_json',2},[{'type',110,'fun',[{'type',110,'product',[{'ann_type',110,[{'var',110,'Source'}|[{'type',110,'any',[]}]]}|[{'ann_type',110,[{'var',110,'Config'}|[{'remote_type',110,[{'atom',110,'jsx_verify'}|[{'atom',110,'config'}|[[]]]]}]]}]]}|[{'type',110,'union',[{'type',110,'boolean',[]}|[{'type',110,'tuple',[{'atom',110,'incomplete'}|[{'user_type',110,'decoder',[]}]]}]]}]]}]}], + %% Line 115 + 'spec' = + %% Line 115 + [{{'is_term',1},[{'type',115,'fun',[{'type',115,'product',[{'ann_type',115,[{'var',115,'Source'}|[{'type',115,'any',[]}]]}]}|[{'type',115,'boolean',[]}]]}]}], + %% Line 119 + 'spec' = + %% Line 119 + [{{'is_term',2},[{'type',119,'fun',[{'type',119,'product',[{'ann_type',119,[{'var',119,'Source'}|[{'type',119,'any',[]}]]}|[{'ann_type',119,[{'var',119,'Config'}|[{'remote_type',119,[{'atom',119,'jsx_verify'}|[{'atom',119,'config'}|[[]]]]}]]}]]}|[{'type',119,'union',[{'type',119,'boolean',[]}|[{'type',119,'tuple',[{'atom',119,'incomplete'}|[{'user_type',119,'encoder',[]}]]}]]}]]}]}], + %% Line 124 + 'spec' = + %% Line 124 + [{{'consult',1},[{'type',124,'fun',[{'type',124,'product',[{'ann_type',124,[{'var',124,'File'}|[{'remote_type',124,[{'atom',124,'file'}|[{'atom',124,'name_all'}|[[]]]]}]]}]}|[{'type',124,'list',[{'user_type',124,'json_term',[]}]}]]}]}], + %% Line 128 + 'spec' = + %% Line 128 + [{{'consult',2},[{'type',128,'fun',[{'type',128,'product',[{'ann_type',128,[{'var',128,'File'}|[{'remote_type',128,[{'atom',128,'file'}|[{'atom',128,'name_all'}|[[]]]]}]]}|[{'ann_type',128,[{'var',128,'Config'}|[{'remote_type',128,[{'atom',128,'jsx_to_term'}|[{'atom',128,'config'}|[[]]]]}]]}]]}|[{'type',128,'list',[{'user_type',128,'json_term',[]}]}]]}]}], + %% Line 133 + 'type' = + %% Line 133 + [{'decoder',{'type',133,'fun',[{'type',133,'product',[{'type',133,'union',[{'user_type',133,'json_text',[]}|[{'atom',133,'end_stream'}|[{'atom',133,'end_json'}]]]}]}|[{'type',133,'any',[]}]]},[]}], + %% Line 135 + 'spec' = + %% Line 135 + [{{'decoder',3},[{'type',135,'fun',[{'type',135,'product',[{'ann_type',135,[{'var',135,'Handler'}|[{'type',135,'module',[]}]]}|[{'ann_type',135,[{'var',135,'State'}|[{'type',135,'any',[]}]]}|[{'ann_type',135,[{'var',135,'Config'}|[{'type',135,'list',[]}]]}]]]}|[{'user_type',135,'decoder',[]}]]}]}], + %% Line 140 + 'type' = + %% Line 140 + [{'encoder',{'type',140,'fun',[{'type',140,'product',[{'type',140,'union',[{'user_type',140,'json_term',[]}|[{'atom',140,'end_stream'}|[{'atom',140,'end_json'}]]]}]}|[{'type',140,'any',[]}]]},[]}], + %% Line 142 + 'spec' = + %% Line 142 + [{{'encoder',3},[{'type',142,'fun',[{'type',142,'product',[{'ann_type',142,[{'var',142,'Handler'}|[{'type',142,'module',[]}]]}|[{'ann_type',142,[{'var',142,'State'}|[{'type',142,'any',[]}]]}|[{'ann_type',142,[{'var',142,'Config'}|[{'type',142,'list',[]}]]}]]]}|[{'user_type',142,'encoder',[]}]]}]}], + %% Line 147 + 'type' = + %% Line 147 + [{'token',{'type',147,'union',[{'type',147,'list',[{'user_type',147,'token',[]}]}|[{'atom',148,'start_object'}|[{'atom',149,'end_object'}|[{'atom',150,'start_array'}|[{'atom',151,'end_array'}|[{'type',152,'tuple',[{'atom',152,'key'}|[{'type',152,'binary',[]}]]}|[{'type',153,'tuple',[{'atom',153,'string'}|[{'type',153,'binary',[]}]]}|[{'type',154,'binary',[]}|[{'type',155,'tuple',[{'atom',155,'number'}|[{'type',155,'union',[{'type',155,'integer',[]}|[{'type',155,'float',[]}]]}]]}|[{'type',156,'tuple',[{'atom',156,'integer'}|[{'type',156,'integer',[]}]]}|[{'type',157,'tuple',[{'atom',157,'float'}|[{'type',157,'float',[]}]]}|[{'type',158,'integer',[]}|[{'type',159,'float',[]}|[{'type',160,'tuple',[{'atom',160,'literal'}|[{'atom',160,'true'}]]}|[{'type',161,'tuple',[{'atom',161,'literal'}|[{'atom',161,'false'}]]}|[{'type',162,'tuple',[{'atom',162,'literal'}|[{'atom',162,'null'}]]}|[{'atom',163,'true'}|[{'atom',164,'false'}|[{'atom',165,'null'}|[{'atom',166,'end_json'}]]]]]]]]]]]]]]]]]]]]},[]}], + %% Line 169 + 'type' = + %% Line 169 + [{'parser',{'type',169,'fun',[{'type',169,'product',[{'type',169,'union',[{'user_type',169,'token',[]}|[{'atom',169,'end_stream'}]]}]}|[{'type',169,'any',[]}]]},[]}], + %% Line 171 + 'spec' = + %% Line 171 + [{{'parser',3},[{'type',171,'fun',[{'type',171,'product',[{'ann_type',171,[{'var',171,'Handler'}|[{'type',171,'module',[]}]]}|[{'ann_type',171,[{'var',171,'State'}|[{'type',171,'any',[]}]]}|[{'ann_type',171,[{'var',171,'Config'}|[{'type',171,'list',[]}]]}]]]}|[{'user_type',171,'parser',[]}]]}]}], + %% Line 175 + 'opaque' = + %% Line 175 + [{'internal_state',{'type',175,'tuple','any'},[]}], + %% Line 177 + 'spec' = + %% Line 177 + [{{'resume',3},[{'type',177,'fun',[{'type',177,'product',[{'ann_type',177,[{'var',177,'Term'}|[{'type',177,'union',[{'user_type',177,'json_text',[]}|[{'user_type',177,'token',[]}]]}]]}|[{'ann_type',177,[{'var',177,'InternalState'}|[{'user_type',177,'internal_state',[]}]]}|[{'ann_type',177,[{'var',177,'Config'}|[{'type',177,'list',[]}]]}]]]}|[{'type',177,'any',[]}]]}]}], + %% Line 185 + 'spec' = + %% Line 185 + [{{'maps_support',0},[{'type',185,'fun',[{'type',185,'product',[]}|[{'type',185,'boolean',[]}]]}]}]] +'encode'/1 = + %% Line 71 + fun (_0) -> + apply 'encode'/2 + (_0, []) +'encode'/2 = + %% Line 75 + fun (_0,_1) -> + call 'jsx_to_json':'to_json' + (_0, _1) +'decode'/1 = + %% Line 80 + fun (_0) -> + apply 'decode'/2 + (_0, []) +'decode'/2 = + %% Line 84 + fun (_0,_1) -> + call 'jsx_to_term':'to_term' + (_0, _1) +'format'/1 = + %% Line 89 + fun (_0) -> + apply 'format'/2 + (_0, []) +'format'/2 = + %% Line 93 + fun (_0,_1) -> + call 'jsx_to_json':'format' + (_0, _1) +'minify'/1 = + %% Line 98 + fun (_0) -> + apply 'format'/2 + (_0, []) +'prettify'/1 = + %% Line 103 + fun (_0) -> + apply 'format'/2 + (_0, ['space'|[{'indent',2}]]) +'is_json'/1 = + %% Line 108 + fun (_0) -> + apply 'is_json'/2 + (_0, []) +'is_json'/2 = + %% Line 112 + fun (_0,_1) -> + call 'jsx_verify':'is_json' + (_0, _1) +'is_term'/1 = + %% Line 117 + fun (_0) -> + apply 'is_term'/2 + (_0, []) +'is_term'/2 = + %% Line 121 + fun (_0,_1) -> + call 'jsx_verify':'is_term' + (_0, _1) +'consult'/1 = + %% Line 126 + fun (_0) -> + apply 'consult'/2 + (_0, []) +'consult'/2 = + %% Line 130 + fun (_0,_1) -> + call 'jsx_consult':'consult' + (_0, _1) +'decoder'/3 = + %% Line 137 + fun (_0,_1,_2) -> + call 'jsx_decoder':'decoder' + (_0, _1, _2) +'encoder'/3 = + %% Line 144 + fun (_0,_1,_2) -> + call 'jsx_encoder':'encoder' + (_0, _1, _2) +'parser'/3 = + %% Line 173 + fun (_0,_1,_2) -> + call 'jsx_parser':'parser' + (_0, _1, _2) +'resume'/3 = + %% Line 179 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + let <_3> = + call %% Line 180 + 'jsx_config':%% Line 180 + 'parse_config' + (%% Line 180 + Config) + in %% Line 180 + call 'jsx_decoder':'resume' + (Term, State, Handler, Acc, Stack, _3) + %% Line 181 + when 'true' -> + let <_4> = + call %% Line 182 + 'jsx_config':%% Line 182 + 'parse_config' + (%% Line 182 + Config) + in %% Line 182 + call 'jsx_parser':'resume' + (Term, State, Handler, Stack, _4) + ( <_7,_6,_5> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_7,_6,_5}) + -| [{'function_name',{'resume',3}}] ) + -| ['compiler_generated'] ) + end +'maps_support'/0 = + %% Line 188 + fun () -> + 'false' +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('jsx') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('jsx', _0) +end \ No newline at end of file diff --git a/test/data/jsx/jsx.erl b/test/data/jsx/jsx.erl new file mode 100644 index 0000000..5062b02 --- /dev/null +++ b/test/data/jsx/jsx.erl @@ -0,0 +1,527 @@ +%% The MIT License + +%% Copyright (c) 2010-2013 alisdair sullivan + +%% Permission is hereby granted, free of charge, to any person obtaining a copy +%% of this software and associated documentation files (the "Software"), to deal +%% in the Software without restriction, including without limitation the rights +%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%% copies of the Software, and to permit persons to whom the Software is +%% furnished to do so, subject to the following conditions: + +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. + +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +%% THE SOFTWARE. + + +-module(jsx). + +-export([encode/1, encode/2, decode/1, decode/2]). +-export([is_json/1, is_json/2, is_term/1, is_term/2]). +-export([format/1, format/2, minify/1, prettify/1]). +-export([consult/1, consult/2]). +-export([encoder/3, decoder/3, parser/3]). +-export([resume/3]). +-export([maps_support/0]). + +-export_type([json_term/0, json_text/0, token/0]). +-export_type([encoder/0, decoder/0, parser/0, internal_state/0]). +-export_type([config/0]). + + +-ifdef(TEST). +%% data and helper functions for tests +-export([test_cases/0, special_test_cases/0]). +-export([init/1, handle_event/2]). +-endif. + + +-ifndef(maps_support). +-type json_term() :: [{binary() | atom(), json_term()}] | [{},...] + | [json_term()] | [] + | true | false | null + | integer() | float() + | binary() | atom() + | calendar:datetime(). +-endif. + +-ifdef(maps_support). +-type json_term() :: [{binary() | atom(), json_term()}] | [{},...] + | [json_term()] | [] + | #{ binary() | atom() => json_term() } + | true | false | null + | integer() | float() + | binary() | atom() + | calendar:datetime(). +-endif. + +-type json_text() :: binary(). + +-type config() :: jsx_config:config(). + +-spec encode(Source::json_term()) -> json_text(). + +encode(Source) -> encode(Source, []). + +-spec encode(Source::json_term(), Config::jsx_to_json:config()) -> json_text() | {incomplete, encoder()}. + +encode(Source, Config) -> jsx_to_json:to_json(Source, Config). + + +-spec decode(Source::json_text()) -> json_term(). + +decode(Source) -> decode(Source, []). + +-spec decode(Source::json_text(), Config::jsx_to_term:config()) -> json_term() | {incomplete, decoder()}. + +decode(Source, Config) -> jsx_to_term:to_term(Source, Config). + + +-spec format(Source::json_text()) -> json_text(). + +format(Source) -> format(Source, []). + +-spec format(Source::json_text(), Config::jsx_to_json:config()) -> json_text() | {incomplete, decoder()}. + +format(Source, Config) -> jsx_to_json:format(Source, Config). + + +-spec minify(Source::json_text()) -> json_text(). + +minify(Source) -> format(Source, []). + + +-spec prettify(Source::json_text()) -> json_text(). + +prettify(Source) -> format(Source, [space, {indent, 2}]). + + +-spec is_json(Source::any()) -> boolean(). + +is_json(Source) -> is_json(Source, []). + +-spec is_json(Source::any(), Config::jsx_verify:config()) -> boolean() | {incomplete, decoder()}. + +is_json(Source, Config) -> jsx_verify:is_json(Source, Config). + + +-spec is_term(Source::any()) -> boolean(). + +is_term(Source) -> is_term(Source, []). + +-spec is_term(Source::any(), Config::jsx_verify:config()) -> boolean() | {incomplete, encoder()}. + +is_term(Source, Config) -> jsx_verify:is_term(Source, Config). + + +-spec consult(File::file:name_all()) -> list(json_term()). + +consult(File) -> consult(File, []). + +-spec consult(File::file:name_all(), Config::jsx_to_term:config()) -> list(json_term()). + +consult(File, Config) -> jsx_consult:consult(File, Config). + + +-type decoder() :: fun((json_text() | end_stream | end_json) -> any()). + +-spec decoder(Handler::module(), State::any(), Config::list()) -> decoder(). + +decoder(Handler, State, Config) -> jsx_decoder:decoder(Handler, State, Config). + + +-type encoder() :: fun((json_term() | end_stream | end_json) -> any()). + +-spec encoder(Handler::module(), State::any(), Config::list()) -> encoder(). + +encoder(Handler, State, Config) -> jsx_encoder:encoder(Handler, State, Config). + + +-type token() :: [token()] + | start_object + | end_object + | start_array + | end_array + | {key, binary()} + | {string, binary()} + | binary() + | {number, integer() | float()} + | {integer, integer()} + | {float, float()} + | integer() + | float() + | {literal, true} + | {literal, false} + | {literal, null} + | true + | false + | null + | end_json. + + +-type parser() :: fun((token() | end_stream) -> any()). + +-spec parser(Handler::module(), State::any(), Config::list()) -> parser(). + +parser(Handler, State, Config) -> jsx_parser:parser(Handler, State, Config). + +-opaque internal_state() :: tuple(). + +-spec resume(Term::json_text() | token(), InternalState::internal_state(), Config::list()) -> any(). + +resume(Term, {decoder, State, Handler, Acc, Stack}, Config) -> + jsx_decoder:resume(Term, State, Handler, Acc, Stack, jsx_config:parse_config(Config)); +resume(Term, {parser, State, Handler, Stack}, Config) -> + jsx_parser:resume(Term, State, Handler, Stack, jsx_config:parse_config(Config)). + + +-spec maps_support() -> boolean(). + +-ifndef(maps_support). +maps_support() -> false. +-endif. +-ifdef(maps_support). +maps_support() -> true. +-endif. + + +-ifdef(TEST). + +-include_lib("eunit/include/eunit.hrl"). + + +%% test handler +init([]) -> []. + +handle_event(end_json, State) -> lists:reverse([end_json] ++ State); +handle_event(Event, State) -> [Event] ++ State. + + +test_cases() -> + empty_array() + ++ nested_array() + ++ empty_object() + ++ nested_object() + ++ strings() + ++ literals() + ++ integers() + ++ floats() + ++ compound_object(). + +%% segregate these so we can skip them in `jsx_to_term` +special_test_cases() -> special_objects() ++ special_array(). + + +empty_array() -> [{"[]", <<"[]">>, [], [start_array, end_array]}]. + + +nested_array() -> + [{ + "[[[]]]", + <<"[[[]]]">>, + [[[]]], + [start_array, start_array, start_array, end_array, end_array, end_array] + }]. + + +empty_object() -> [{"{}", <<"{}">>, [{}], [start_object, end_object]}]. + + +nested_object() -> + [{ + "{\"key\":{\"key\":{}}}", + <<"{\"key\":{\"key\":{}}}">>, + [{<<"key">>, [{<<"key">>, [{}]}]}], + [ + start_object, + {key, <<"key">>}, + start_object, + {key, <<"key">>}, + start_object, + end_object, + end_object, + end_object + ] + }]. + + +naked_strings() -> + Raw = [ + "", + "hello world" + ], + [ + { + String, + <<"\"", (list_to_binary(String))/binary, "\"">>, + list_to_binary(String), + [{string, list_to_binary(String)}] + } + || String <- Raw + ]. + + +strings() -> + naked_strings() + ++ [ wrap_with_array(Test) || Test <- naked_strings() ] + ++ [ wrap_with_object(Test) || Test <- naked_strings() ]. + + +naked_integers() -> + Raw = [ + 1, 2, 3, + 127, 128, 129, + 255, 256, 257, + 65534, 65535, 65536, + 18446744073709551616, + 18446744073709551617 + ], + [ + { + integer_to_list(X), + list_to_binary(integer_to_list(X)), + X, + [{integer, X}] + } + || X <- Raw ++ [ -1 * Y || Y <- Raw ] ++ [0] + ]. + + +integers() -> + naked_integers() + ++ [ wrap_with_array(Test) || Test <- naked_integers() ] + ++ [ wrap_with_object(Test) || Test <- naked_integers() ]. + + +naked_floats() -> + Raw = [ + 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, + 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, + 1234567890.0987654321, + 0.0e0, + 1234567890.0987654321e16, + 0.1e0, 0.1e1, 0.1e2, 0.1e4, 0.1e8, 0.1e16, 0.1e308, + 1.0e0, 1.0e1, 1.0e2, 1.0e4, 1.0e8, 1.0e16, 1.0e308, + 2.2250738585072014e-308, %% min normalized float + 1.7976931348623157e308, %% max normalized float + 5.0e-324, %% min denormalized float + 2.225073858507201e-308 %% max denormalized float + ], + [ + { + sane_float_to_list(X), + list_to_binary(sane_float_to_list(X)), + X, + [{float, X}] + } + || X <- Raw ++ [ -1 * Y || Y <- Raw ] + ]. + + +floats() -> + naked_floats() + ++ [ wrap_with_array(Test) || Test <- naked_floats() ] + ++ [ wrap_with_object(Test) || Test <- naked_floats() ]. + + +naked_literals() -> + [ + { + atom_to_list(Literal), + atom_to_binary(Literal, unicode), + Literal, + [{literal, Literal}] + } + || Literal <- [true, false, null] + ]. + + +literals() -> + naked_literals() + ++ [ wrap_with_array(Test) || Test <- naked_literals() ] + ++ [ wrap_with_object(Test) || Test <- naked_literals() ]. + + +compound_object() -> + [{ + "[{\"alpha\":[1,2,3],\"beta\":{\"alpha\":[1.0,2.0,3.0],\"beta\":[true,false]}},[{}]]", + <<"[{\"alpha\":[1,2,3],\"beta\":{\"alpha\":[1.0,2.0,3.0],\"beta\":[true,false]}},[{}]]">>, + [[{<<"alpha">>, [1, 2, 3]}, {<<"beta">>, [{<<"alpha">>, [1.0, 2.0, 3.0]}, {<<"beta">>, [true, false]}]}], [[{}]]], + [ + start_array, + start_object, + {key, <<"alpha">>}, + start_array, + {integer, 1}, + {integer, 2}, + {integer, 3}, + end_array, + {key, <<"beta">>}, + start_object, + {key, <<"alpha">>}, + start_array, + {float, 1.0}, + {float, 2.0}, + {float, 3.0}, + end_array, + {key, <<"beta">>}, + start_array, + {literal, true}, + {literal, false}, + end_array, + end_object, + end_object, + start_array, + start_object, + end_object, + end_array, + end_array + ] + }]. + + +special_objects() -> + [ + { + "[{key, atom}]", + <<"{\"key\":\"atom\"}">>, + [{key, atom}], + [start_object, {key, <<"key">>}, {string, <<"atom">>}, end_object] + }, + { + "[{1, true}]", + <<"{\"1\":true}">>, + [{1, true}], + [start_object, {key, <<"1">>}, {literal, true}, end_object] + } + ]. + + +special_array() -> + [ + { + "[foo, bar]", + <<"[\"foo\",\"bar\"]">>, + [foo, bar], + [start_array, {string, <<"foo">>}, {string, <<"bar">>}, end_array] + } + ]. + + +wrap_with_array({Title, JSON, Term, Events}) -> + { + "[" ++ Title ++ "]", + <<"[", JSON/binary, "]">>, + [Term], + [start_array] ++ Events ++ [end_array] + }. + + +wrap_with_object({Title, JSON, Term, Events}) -> + { + "{\"key\":" ++ Title ++ "}", + <<"{\"key\":", JSON/binary, "}">>, + [{<<"key">>, Term}], + [start_object, {key, <<"key">>}] ++ Events ++ [end_object] + }. + + +sane_float_to_list(X) -> + [Output] = io_lib:format("~p", [X]), + Output. + + +incremental_decode(JSON) -> + Final = lists:foldl( + fun(Byte, Decoder) -> {incomplete, F} = Decoder(Byte), F end, + decoder(jsx, [], [stream]), + json_to_bytes(JSON) + ), + Final(end_stream). + + +incremental_parse(Events) -> + Final = lists:foldl( + fun(Event, Parser) -> {incomplete, F} = Parser(Event), F end, + parser(?MODULE, [], [stream]), + lists:map(fun(X) -> [X] end, Events) + ), + Final(end_stream). + + +%% used to convert a json text into a list of codepoints to be incrementally +%% parsed +json_to_bytes(JSON) -> json_to_bytes(JSON, []). + +json_to_bytes(<<>>, Acc) -> [<<>>] ++ lists:reverse(Acc); +json_to_bytes(<>, Acc) -> json_to_bytes(Rest, [<>] ++ Acc). + + +%% actual tests! +decode_test_() -> + Data = test_cases(), + [{Title, ?_assertEqual(Events ++ [end_json], (decoder(?MODULE, [], []))(JSON))} + || {Title, JSON, _, Events} <- Data + ] ++ + [{Title ++ " (incremental)", ?_assertEqual(Events ++ [end_json], incremental_decode(JSON))} + || {Title, JSON, _, Events} <- Data + ]. + + +parse_test_() -> + Data = test_cases(), + [{Title, ?_assertEqual(Events ++ [end_json], (parser(?MODULE, [], []))(Events ++ [end_json]))} + || {Title, _, _, Events} <- Data + ] ++ + [{Title ++ " (incremental)", ?_assertEqual(Events ++ [end_json], incremental_parse(Events))} + || {Title, _, _, Events} <- Data + ]. + + +encode_test_() -> + Data = test_cases(), + [ + { + Title, ?_assertEqual( + Events ++ [end_json], + (jsx:encoder(jsx, [], []))(Term) + ) + } || {Title, _, Term, Events} <- Data + ]. + +end_stream_test_() -> + Tokens = [start_object, end_object, end_json], + [ + {"encoder end_stream", ?_assertEqual( + Tokens, + begin + {incomplete, F} = (jsx:parser(jsx, [], [stream]))([start_object, end_object]), + F(end_stream) + end + )}, + {"encoder end_json", ?_assertEqual( + Tokens, + begin + {incomplete, F} = (jsx:parser(jsx, [], [stream]))([start_object, end_object]), + F(end_json) + end + )}, + {"decoder end_stream", ?_assertEqual( + Tokens, + begin {incomplete, F} = (jsx:decoder(jsx, [], [stream]))(<<"{}">>), F(end_stream) end + )}, + {"decoder end_json", ?_assertEqual( + Tokens, + begin {incomplete, F} = (jsx:decoder(jsx, [], [stream]))(<<"{}">>), F(end_json) end + )} + ]. + + +-endif. diff --git a/test/data/jsx/jsx_config.core b/test/data/jsx/jsx_config.core new file mode 100644 index 0000000..942172c --- /dev/null +++ b/test/data/jsx/jsx_config.core @@ -0,0 +1,734 @@ +module 'jsx_config' ['config_to_list'/1, + 'extract_config'/1, + 'module_info'/0, + 'module_info'/1, + 'parse_config'/1, + 'valid_flags'/0] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[99|[111|[110|[102|[105|[103|[46|[101|[114|[108]]]]]]]]]]]]]],1}], + %% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[99|[111|[110|[102|[105|[103|[46|[104|[114|[108]]]]]]]]]]]]]],1}], + %% Line 1 + 'record' = + %% Line 1 + [{'config',[{'typed_record_field',{'record_field',2,{'atom',2,'dirty_strings'},{'atom',2,'false'}},{'type',2,'boolean',[]}}|[{'typed_record_field',{'record_field',3,{'atom',3,'escaped_forward_slashes'},{'atom',3,'false'}},{'type',3,'boolean',[]}}|[{'typed_record_field',{'record_field',4,{'atom',4,'escaped_strings'},{'atom',4,'false'}},{'type',4,'boolean',[]}}|[{'typed_record_field',{'record_field',5,{'atom',5,'multi_term'},{'atom',5,'false'}},{'type',5,'boolean',[]}}|[{'typed_record_field',{'record_field',6,{'atom',6,'strict_comments'},{'atom',6,'false'}},{'type',6,'boolean',[]}}|[{'typed_record_field',{'record_field',7,{'atom',7,'strict_commas'},{'atom',7,'false'}},{'type',7,'boolean',[]}}|[{'typed_record_field',{'record_field',8,{'atom',8,'strict_utf8'},{'atom',8,'false'}},{'type',8,'boolean',[]}}|[{'typed_record_field',{'record_field',9,{'atom',9,'strict_single_quotes'},{'atom',9,'false'}},{'type',9,'boolean',[]}}|[{'typed_record_field',{'record_field',10,{'atom',10,'strict_escapes'},{'atom',10,'false'}},{'type',10,'boolean',[]}}|[{'typed_record_field',{'record_field',11,{'atom',11,'strict_control_codes'},{'atom',11,'false'}},{'type',11,'boolean',[]}}|[{'typed_record_field',{'record_field',12,{'atom',12,'stream'},{'atom',12,'false'}},{'type',12,'boolean',[]}}|[{'typed_record_field',{'record_field',13,{'atom',13,'return_tail'},{'atom',13,'false'}},{'type',13,'boolean',[]}}|[{'typed_record_field',{'record_field',14,{'atom',14,'uescape'},{'atom',14,'false'}},{'type',14,'boolean',[]}}|[{'typed_record_field',{'record_field',15,{'atom',15,'unescaped_jsonp'},{'atom',15,'false'}},{'type',15,'boolean',[]}}|[{'typed_record_field',{'record_field',16,{'atom',16,'error_handler'},{'atom',16,'false'}},{'type',16,'union',[{'atom',16,'false'}|[{'remote_type',16,[{'atom',16,'jsx_config'}|[{'atom',16,'handler'}|[[]]]]}]]}}|[{'typed_record_field',{'record_field',17,{'atom',17,'incomplete_handler'},{'atom',17,'false'}},{'type',17,'union',[{'atom',17,'false'}|[{'remote_type',17,[{'atom',17,'jsx_config'}|[{'atom',17,'handler'}|[[]]]]}]]}}]]]]]]]]]]]]]]]]}], + %% Line 35 + 'file' = + %% Line 35 + [{[106|[115|[120|[95|[99|[111|[110|[102|[105|[103|[46|[101|[114|[108]]]]]]]]]]]]]],35}], + %% Line 36 + 'type' = + %% Line 36 + [{'handler_type',{'type',37,'fun',[{'type',37,'product',[{'type',37,'union',[{'remote_type',37,[{'atom',37,'jsx'}|[{'atom',37,'json_text'}|[[]]]]}|[{'atom',37,'end_stream'}|[{'remote_type',38,[{'atom',38,'jsx'}|[{'atom',38,'json_term'}|[[]]]]}]]]}|[{'type',39,'union',[{'type',39,'tuple',[{'atom',39,'decoder'}|[{'type',39,'any',[]}|[{'type',39,'module',[]}|[{'type',39,'union',[{'atom',39,'null'}|[{'type',39,'list',[]}]]}|[{'type',39,'list',[]}]]]]]}|[{'type',40,'tuple',[{'atom',40,'parser'}|[{'type',40,'any',[]}|[{'type',40,'module',[]}|[{'type',40,'list',[]}]]]]}|[{'type',41,'tuple',[{'atom',41,'encoder'}|[{'type',41,'any',[]}|[{'type',41,'module',[]}]]]}]]]}|[{'type',42,'list',[{'type',42,'union',[{'type',42,'tuple',[{'atom',42,'pre_encode'}|[{'type',42,'fun',[{'type',42,'product',[{'type',42,'any',[]}]}|[{'type',42,'any',[]}]]}]]}|[{'type',43,'tuple',[{'atom',43,'error_handler'}|[{'var',43,'Handler'}]]}|[{'type',44,'tuple',[{'atom',44,'incomplete_handler'}|[{'var',44,'Handler'}]]}|[{'type',45,'atom',[]}]]]]}]}]]]}|[{'type',45,'any',[]}]]},[{'var',36,'Handler'}]}], + %% Line 46 + 'type' = + %% Line 46 + [{'handler',{'user_type',46,'handler_type',[{'user_type',46,'handler',[]}]},[]}], + %% Line 47 + 'export_type' = + %% Line 47 + [{'handler',0}], + %% Line 49 + 'type' = + %% Line 49 + [{'config',{'type',49,'record',[{'atom',49,'config'}]},[]}], + %% Line 50 + 'export_type' = + %% Line 50 + [{'config',0}], + %% Line 53 + 'spec' = + %% Line 53 + [{{'parse_config',1},[{'type',53,'fun',[{'type',53,'product',[{'ann_type',53,[{'var',53,'Config'}|[{'remote_type',53,[{'atom',53,'proplists'}|[{'atom',53,'proplist'}|[[]]]]}]]}]}|[{'user_type',53,'config',[]}]]}]}], + %% Line 119 + 'spec' = + %% Line 119 + [{{'config_to_list',1},[{'type',119,'fun',[{'type',119,'product',[{'ann_type',119,[{'var',119,'Config'}|[{'user_type',119,'config',[]}]]}]}|[{'remote_type',119,[{'atom',119,'proplists'}|[{'atom',119,'proplist'}|[[]]]]}]]}]}], + %% Line 156 + 'spec' = + %% Line 156 + [{{'valid_flags',0},[{'type',156,'fun',[{'type',156,'product',[]}|[{'type',156,'list',[{'type',156,'atom',[]}]}]]}]}], + %% Line 175 + 'spec' = + %% Line 175 + [{{'extract_config',1},[{'type',175,'fun',[{'type',175,'product',[{'ann_type',175,[{'var',175,'Config'}|[{'remote_type',175,[{'atom',175,'proplists'}|[{'atom',175,'proplist'}|[[]]]]}]]}]}|[{'remote_type',175,[{'atom',175,'proplists'}|[{'atom',175,'proplist'}|[[]]]]}]]}]}]] +'parse_config'/1 = + %% Line 55 + fun (_0) -> + apply 'parse_config'/2 + (_0, {'config','false','false','false','false','false','false','false','false','false','false','false','false','false','false','false','false'}) +'parse_config'/2 = + %% Line 57 + fun (_0,_1) -> + case <_0,_1> of + <[],Config> when 'true' -> + Config + %% Line 58 + <['escaped_forward_slashes'|Rest],Config> when 'true' -> + %% Line 59 + case Config of + <{'config',_48,_49,_50,_51,_52,_53,_54,_55,_56,_57,_58,_59,_60,_61,_62,_63}> when 'true' -> + let <_4> = + call 'erlang':'setelement' + (3, Config, 'true') + in apply 'parse_config'/2 + (Rest, _4) + ( <_64> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 60 + <['escaped_strings'|Rest],Config> when 'true' -> + %% Line 61 + case Config of + <{'config',_65,_66,_67,_68,_69,_70,_71,_72,_73,_74,_75,_76,_77,_78,_79,_80}> when 'true' -> + let <_7> = + call 'erlang':'setelement' + (4, Config, 'true') + in apply 'parse_config'/2 + (Rest, _7) + ( <_81> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 62 + <['unescaped_jsonp'|Rest],Config> when 'true' -> + %% Line 63 + case Config of + <{'config',_82,_83,_84,_85,_86,_87,_88,_89,_90,_91,_92,_93,_94,_95,_96,_97}> when 'true' -> + let <_10> = + call 'erlang':'setelement' + (15, Config, 'true') + in apply 'parse_config'/2 + (Rest, _10) + ( <_98> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 64 + <['dirty_strings'|Rest],Config> when 'true' -> + %% Line 65 + case Config of + <{'config',_99,_100,_101,_102,_103,_104,_105,_106,_107,_108,_109,_110,_111,_112,_113,_114}> when 'true' -> + let <_13> = + call 'erlang':'setelement' + (2, Config, 'true') + in apply 'parse_config'/2 + (Rest, _13) + ( <_115> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 66 + <['multi_term'|Rest],Config> when 'true' -> + %% Line 67 + case Config of + <{'config',_116,_117,_118,_119,_120,_121,_122,_123,_124,_125,_126,_127,_128,_129,_130,_131}> when 'true' -> + let <_16> = + call 'erlang':'setelement' + (5, Config, 'true') + in apply 'parse_config'/2 + (Rest, _16) + ( <_132> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 68 + <['return_tail'|Rest],Config> when 'true' -> + %% Line 69 + case Config of + <{'config',_133,_134,_135,_136,_137,_138,_139,_140,_141,_142,_143,_144,_145,_146,_147,_148}> when 'true' -> + let <_19> = + call 'erlang':'setelement' + (13, Config, 'true') + in apply 'parse_config'/2 + (Rest, _19) + ( <_149> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 71 + <['repeat_keys'|Rest],Config> when 'true' -> + %% Line 72 + apply 'parse_config'/2 + (Rest, Config) + %% Line 73 + <['uescape'|Rest],Config> when 'true' -> + %% Line 74 + case Config of + <{'config',_150,_151,_152,_153,_154,_155,_156,_157,_158,_159,_160,_161,_162,_163,_164,_165}> when 'true' -> + let <_22> = + call 'erlang':'setelement' + (14, Config, 'true') + in apply 'parse_config'/2 + (Rest, _22) + ( <_166> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 75 + <['strict'|Rest],Config> when 'true' -> + %% Line 77 + case Config of + <{'config',_167,_168,_169,_170,_171,_172,_173,_174,_175,_176,_177,_178,_179,_180,_181,_182}> when 'true' -> + let <_24> = + call %% Line 82 + 'erlang':%% Line 82 + 'setelement' + (%% Line 82 + 11, Config, %% Line 82 + 'true') + in let <_25> = + call %% Line 81 + 'erlang':%% Line 81 + 'setelement' + (%% Line 81 + 10, _24, %% Line 81 + 'true') + in let <_26> = + call %% Line 80 + 'erlang':%% Line 80 + 'setelement' + (%% Line 80 + 9, _25, %% Line 80 + 'true') + in let <_27> = + call %% Line 79 + 'erlang':%% Line 79 + 'setelement' + (%% Line 79 + 8, _26, %% Line 79 + 'true') + in let <_28> = + call %% Line 78 + 'erlang':%% Line 78 + 'setelement' + (%% Line 78 + 7, _27, %% Line 78 + 'true') + in let <_30> = + call 'erlang':'setelement' + (6, _28, 'true') + in apply 'parse_config'/2 + (Rest, _30) + ( <_183> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 84 + <[{'strict',Strict}|Rest],Config> when 'true' -> + %% Line 85 + apply 'parse_strict'/3 + (Strict, Rest, Config) + %% Line 86 + <['stream'|Rest],Config> when 'true' -> + %% Line 87 + case Config of + <{'config',_184,_185,_186,_187,_188,_189,_190,_191,_192,_193,_194,_195,_196,_197,_198,_199}> when 'true' -> + let <_33> = + call 'erlang':'setelement' + (12, Config, 'true') + in apply 'parse_config'/2 + (Rest, _33) + ( <_200> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 88 + + when call 'erlang':'is_function' + (ErrorHandler, + 3) -> + %% Line 89 + ( case Config of + ( <( {'config',_201,_202,_203,_204,_205,_206,_207,_208,_209,_210,_211,_212,_213,_214,_rec9,_215} + -| ['compiler_generated'] )> when 'true' -> + case _rec9 of + %% Line 90 + <'false'> when 'true' -> + case Config of + <{'config',_217,_218,_219,_220,_221,_222,_223,_224,_225,_226,_227,_228,_229,_230,_231,_232}> when 'true' -> + let <_38> = + call 'erlang':'setelement' + (16, Config, ErrorHandler) + in apply 'parse_config'/2 + (Rest, _38) + ( <_233> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 91 + <_234> when 'true' -> + call 'erlang':'error' + ('badarg', [Options|[Config|[]]]) + end + -| ['compiler_generated'] ) + ( <_216> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 93 + + when call 'erlang':'is_function' + (IncompleteHandler, + 3) -> + %% Line 94 + ( case Config of + ( <( {'config',_235,_236,_237,_238,_239,_240,_241,_242,_243,_244,_245,_246,_247,_248,_249,_rec11} + -| ['compiler_generated'] )> when 'true' -> + case _rec11 of + %% Line 95 + <'false'> when 'true' -> + case Config of + <{'config',_251,_252,_253,_254,_255,_256,_257,_258,_259,_260,_261,_262,_263,_264,_265,_266}> when 'true' -> + let <_44> = + call 'erlang':'setelement' + (17, Config, IncompleteHandler) + in apply 'parse_config'/2 + (Rest, _44) + ( <_267> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 96 + <_268> when 'true' -> + call 'erlang':'error' + ('badarg', [Options|[Config|[]]]) + end + -| ['compiler_generated'] ) + ( <_250> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 98 + <_X_Options,_X_Config> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'parse_strict'/3 = + %% Line 101 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <[],Rest,Config> when 'true' -> + apply 'parse_config'/2 + (Rest, Config) + %% Line 102 + <['comments'|Strict],Rest,Config> when 'true' -> + %% Line 103 + case Config of + <{'config',_24,_25,_26,_27,_28,_29,_30,_31,_32,_33,_34,_35,_36,_37,_38,_39}> when 'true' -> + let <_5> = + call 'erlang':'setelement' + (6, Config, 'true') + in apply 'parse_strict'/3 + (Strict, Rest, _5) + ( <_40> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 104 + <['trailing_commas'|Strict],Rest,Config> when 'true' -> + %% Line 105 + case Config of + <{'config',_41,_42,_43,_44,_45,_46,_47,_48,_49,_50,_51,_52,_53,_54,_55,_56}> when 'true' -> + let <_8> = + call 'erlang':'setelement' + (7, Config, 'true') + in apply 'parse_strict'/3 + (Strict, Rest, _8) + ( <_57> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 106 + <['utf8'|Strict],Rest,Config> when 'true' -> + %% Line 107 + case Config of + <{'config',_58,_59,_60,_61,_62,_63,_64,_65,_66,_67,_68,_69,_70,_71,_72,_73}> when 'true' -> + let <_11> = + call 'erlang':'setelement' + (8, Config, 'true') + in apply 'parse_strict'/3 + (Strict, Rest, _11) + ( <_74> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 108 + <['single_quotes'|Strict],Rest,Config> when 'true' -> + %% Line 109 + case Config of + <{'config',_75,_76,_77,_78,_79,_80,_81,_82,_83,_84,_85,_86,_87,_88,_89,_90}> when 'true' -> + let <_14> = + call 'erlang':'setelement' + (9, Config, 'true') + in apply 'parse_strict'/3 + (Strict, Rest, _14) + ( <_91> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 110 + <['escapes'|Strict],Rest,Config> when 'true' -> + %% Line 111 + case Config of + <{'config',_92,_93,_94,_95,_96,_97,_98,_99,_100,_101,_102,_103,_104,_105,_106,_107}> when 'true' -> + let <_17> = + call 'erlang':'setelement' + (10, Config, 'true') + in apply 'parse_strict'/3 + (Strict, Rest, _17) + ( <_108> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 112 + <['control_codes'|Strict],Rest,Config> when 'true' -> + %% Line 113 + case Config of + <{'config',_109,_110,_111,_112,_113,_114,_115,_116,_117,_118,_119,_120,_121,_122,_123,_124}> when 'true' -> + let <_20> = + call 'erlang':'setelement' + (11, Config, 'true') + in apply 'parse_strict'/3 + (Strict, Rest, _20) + ( <_125> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 114 + <_X_Strict,_X_Rest,_X_Config> when 'true' -> + %% Line 115 + call 'erlang':'error' + ('badarg') + end +'config_to_list'/1 = + %% Line 121 + fun (_0) -> + let <_10> = + fun (_8) -> + %% Line 123 + case _8 of + <_@r0 = {'error_handler',F}> when 'true' -> + _@r0 + %% Line 124 + <_@r1 = {'incomplete_handler',F}> when 'true' -> + _@r1 + %% Line 125 + <{Key,'true'}> when 'true' -> + Key + ( <_9> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_9}) + -| [{'function_name',{'-config_to_list/1-fun-1-',1}}] ) + -| ['compiler_generated'] ) + end + in let <_6> = + fun (_4) -> + %% Line 128 + case _4 of + <{_13,'false'}> when 'true' -> + 'false' + <_14> when 'true' -> + 'true' + end + in let <_1> = + call %% Line 129 + 'erlang':%% Line 129 + 'tuple_to_list' + (_0) + in let <_2> = + call %% Line 129 + 'erlang':%% Line 129 + 'tl' + (_1) + in let <_3> = + call %% Line 129 + 'lists':%% Line 129 + 'zip' + (%% Line 129 + ['dirty_strings'|['escaped_forward_slashes'|['escaped_strings'|['multi_term'|['strict_comments'|['strict_commas'|['strict_utf8'|['strict_single_quotes'|['strict_escapes'|['strict_control_codes'|['stream'|['return_tail'|['uescape'|['unescaped_jsonp'|['error_handler'|['incomplete_handler']]]]]]]]]]]]]]]], _2) + in let <_7> = + call %% Line 127 + 'lists':%% Line 127 + 'filter' + (_6, _3) + in let <_11> = + call %% Line 122 + 'lists':%% Line 122 + 'map' + (_10, _7) + in %% Line 122 + apply 'reduce_config'/1 + (_11) +'reduce_config'/1 = + %% Line 134 + fun (_0) -> + apply 'reduce_config'/3 + (_0, [], []) +'reduce_config'/3 = + %% Line 136 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <[],Output,Strict> when 'true' -> + %% Line 137 + case call 'erlang':'length' + (Strict) of + %% Line 138 + <0> when 'true' -> + call 'lists':'reverse' + (Output) + %% Line 139 + <5> when 'true' -> + let <_3> = + call 'lists':'reverse' + (Output) + in call 'erlang':'++' + (_3, ['strict']) + %% Line 140 + <_16> when 'true' -> + let <_5> = + call 'lists':'reverse' + (Output) + in let <_4> = + call 'lists':'reverse' + (Strict) + in call 'erlang':'++' + (_5, [{'strict',_4}|[]]) + end + %% Line 142 + <['strict_comments'|Input],Output,Strict> when 'true' -> + let <_7> = + ['comments'|%% Line 143 + Strict] + in %% Line 143 + apply 'reduce_config'/3 + (Input, Output, _7) + %% Line 144 + <['strict_utf8'|Input],Output,Strict> when 'true' -> + let <_8> = + ['utf8'|%% Line 145 + Strict] + in %% Line 145 + apply 'reduce_config'/3 + (Input, Output, _8) + %% Line 146 + <['strict_single_quotes'|Input],Output,Strict> when 'true' -> + let <_9> = + ['single_quotes'|%% Line 147 + Strict] + in %% Line 147 + apply 'reduce_config'/3 + (Input, Output, _9) + %% Line 148 + <['strict_escapes'|Input],Output,Strict> when 'true' -> + let <_10> = + ['escapes'|%% Line 149 + Strict] + in %% Line 149 + apply 'reduce_config'/3 + (Input, Output, _10) + %% Line 150 + <['strict_control_codes'|Input],Output,Strict> when 'true' -> + let <_11> = + ['control_codes'|%% Line 151 + Strict] + in %% Line 151 + apply 'reduce_config'/3 + (Input, Output, _11) + %% Line 152 + <[Else|Input],Output,Strict> when 'true' -> + let <_12> = + [%% Line 153 + Else|%% Line 153 + Output] + in %% Line 153 + apply 'reduce_config'/3 + (Input, _12, Strict) + ( <_15,_14,_13> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_15,_14,_13}) + -| [{'function_name',{'reduce_config',3}}] ) + -| ['compiler_generated'] ) + end +'valid_flags'/0 = + %% Line 158 + fun () -> + %% Line 159 + ['escaped_forward_slashes'|['escaped_strings'|['unescaped_jsonp'|['dirty_strings'|['multi_term'|['return_tail'|['repeat_keys'|['strict'|['stream'|['uescape'|['error_handler'|['incomplete_handler']]]]]]]]]]]] +'extract_config'/1 = + %% Line 177 + fun (_0) -> + %% Line 178 + apply 'extract_parser_config'/2 + (_0, []) +'extract_parser_config'/2 = + %% Line 180 + fun (_0,_1) -> + case <_0,_1> of + <[],Acc> when 'true' -> + Acc + %% Line 181 + <[_@r0 = {K,V}|Rest],Acc> when 'true' -> + let <_2> = + apply %% Line 182 + 'valid_flags'/0 + () + in %% Line 182 + case call 'lists':'member' + (K, _2) of + %% Line 183 + <'true'> when 'true' -> + let <_3> = + [_@r0|Acc] + in apply 'extract_parser_config'/2 + (Rest, _3) + %% Line 184 + <'false'> when 'true' -> + apply 'extract_parser_config'/2 + (Rest, Acc) + ( <_4> when 'true' -> + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end + %% Line 186 + <[K|Rest],Acc> when 'true' -> + let <_5> = + apply %% Line 187 + 'valid_flags'/0 + () + in %% Line 187 + case call 'lists':'member' + (K, _5) of + %% Line 188 + <'true'> when 'true' -> + let <_6> = + [K|Acc] + in apply 'extract_parser_config'/2 + (Rest, _6) + %% Line 189 + <'false'> when 'true' -> + apply 'extract_parser_config'/2 + (Rest, Acc) + ( <_7> when 'true' -> + primop 'match_fail' + ({'case_clause',_7}) + -| ['compiler_generated'] ) + end + ( <_9,_8> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_9,_8}) + -| [{'function_name',{'extract_parser_config',2}}] ) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('jsx_config') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('jsx_config', _0) +end \ No newline at end of file diff --git a/test/data/jsx/jsx_config.erl b/test/data/jsx/jsx_config.erl new file mode 100644 index 0000000..47cbcf7 --- /dev/null +++ b/test/data/jsx/jsx_config.erl @@ -0,0 +1,346 @@ +%% The MIT License + +%% Copyright (c) 2010-2013 alisdair sullivan + +%% Permission is hereby granted, free of charge, to any person obtaining a copy +%% of this software and associated documentation files (the "Software"), to deal +%% in the Software without restriction, including without limitation the rights +%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%% copies of the Software, and to permit persons to whom the Software is +%% furnished to do so, subject to the following conditions: + +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. + +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +%% THE SOFTWARE. + + +-module(jsx_config). + +-export([parse_config/1]). +-export([config_to_list/1]). +-export([extract_config/1, valid_flags/0]). + +-ifdef(TEST). +-export([fake_error_handler/3]). +-endif. + +-include("jsx_config.hrl"). + +-type handler_type(Handler) :: + fun((jsx:json_text() | end_stream | + jsx:json_term(), + {decoder, any(), module(), null | list(), list()} | + {parser, any(), module(), list()} | + {encoder, any(), module()}, + list({pre_encode, fun((any()) -> any())} | + {error_handler, Handler} | + {incomplete_handler, Handler} | + atom())) -> any()). +-type handler() :: handler_type(handler()). +-export_type([handler/0]). + +-type config() :: #config{}. +-export_type([config/0]). + +%% parsing of jsx config +-spec parse_config(Config::proplists:proplist()) -> config(). + +parse_config(Config) -> parse_config(Config, #config{}). + +parse_config([], Config) -> Config; +parse_config([escaped_forward_slashes|Rest], Config) -> + parse_config(Rest, Config#config{escaped_forward_slashes=true}); +parse_config([escaped_strings|Rest], Config) -> + parse_config(Rest, Config#config{escaped_strings=true}); +parse_config([unescaped_jsonp|Rest], Config) -> + parse_config(Rest, Config#config{unescaped_jsonp=true}); +parse_config([dirty_strings|Rest], Config) -> + parse_config(Rest, Config#config{dirty_strings=true}); +parse_config([multi_term|Rest], Config) -> + parse_config(Rest, Config#config{multi_term=true}); +parse_config([return_tail|Rest], Config) -> + parse_config(Rest, Config#config{return_tail=true}); +%% retained for backwards compat, now does nothing however +parse_config([repeat_keys|Rest], Config) -> + parse_config(Rest, Config); +parse_config([uescape|Rest], Config) -> + parse_config(Rest, Config#config{uescape=true}); +parse_config([strict|Rest], Config) -> + parse_config(Rest, Config#config{ + strict_comments=true, + strict_commas=true, + strict_utf8=true, + strict_single_quotes=true, + strict_escapes=true, + strict_control_codes=true + }); +parse_config([{strict, Strict}|Rest], Config) -> + parse_strict(Strict, Rest, Config); +parse_config([stream|Rest], Config) -> + parse_config(Rest, Config#config{stream=true}); +parse_config([{error_handler, ErrorHandler}|Rest] = Options, Config) when is_function(ErrorHandler, 3) -> + case Config#config.error_handler of + false -> parse_config(Rest, Config#config{error_handler=ErrorHandler}) + ; _ -> erlang:error(badarg, [Options, Config]) + end; +parse_config([{incomplete_handler, IncompleteHandler}|Rest] = Options, Config) when is_function(IncompleteHandler, 3) -> + case Config#config.incomplete_handler of + false -> parse_config(Rest, Config#config{incomplete_handler=IncompleteHandler}) + ; _ -> erlang:error(badarg, [Options, Config]) + end; +parse_config(_Options, _Config) -> erlang:error(badarg). + + +parse_strict([], Rest, Config) -> parse_config(Rest, Config); +parse_strict([comments|Strict], Rest, Config) -> + parse_strict(Strict, Rest, Config#config{strict_comments=true}); +parse_strict([trailing_commas|Strict], Rest, Config) -> + parse_strict(Strict, Rest, Config#config{strict_commas=true}); +parse_strict([utf8|Strict], Rest, Config) -> + parse_strict(Strict, Rest, Config#config{strict_utf8=true}); +parse_strict([single_quotes|Strict], Rest, Config) -> + parse_strict(Strict, Rest, Config#config{strict_single_quotes=true}); +parse_strict([escapes|Strict], Rest, Config) -> + parse_strict(Strict, Rest, Config#config{strict_escapes=true}); +parse_strict([control_codes|Strict], Rest, Config) -> + parse_strict(Strict, Rest, Config#config{strict_control_codes=true}); +parse_strict(_Strict, _Rest, _Config) -> + erlang:error(badarg). + + + +-spec config_to_list(Config::config()) -> proplists:proplist(). + +config_to_list(Config) -> + reduce_config(lists:map( + fun ({error_handler, F}) -> {error_handler, F}; + ({incomplete_handler, F}) -> {incomplete_handler, F}; + ({Key, true}) -> Key + end, + lists:filter( + fun({_, false}) -> false; (_) -> true end, + lists:zip(record_info(fields, config), tl(tuple_to_list(Config))) + ) + )). + + +reduce_config(Input) -> reduce_config(Input, [], []). + +reduce_config([], Output, Strict) -> + case length(Strict) of + 0 -> lists:reverse(Output); + 5 -> lists:reverse(Output) ++ [strict]; + _ -> lists:reverse(Output) ++ [{strict, lists:reverse(Strict)}] + end; +reduce_config([strict_comments|Input], Output, Strict) -> + reduce_config(Input, Output, [comments] ++ Strict); +reduce_config([strict_utf8|Input], Output, Strict) -> + reduce_config(Input, Output, [utf8] ++ Strict); +reduce_config([strict_single_quotes|Input], Output, Strict) -> + reduce_config(Input, Output, [single_quotes] ++ Strict); +reduce_config([strict_escapes|Input], Output, Strict) -> + reduce_config(Input, Output, [escapes] ++ Strict); +reduce_config([strict_control_codes|Input], Output, Strict) -> + reduce_config(Input, Output, [control_codes] ++ Strict); +reduce_config([Else|Input], Output, Strict) -> + reduce_config(Input, [Else] ++ Output, Strict). + + +-spec valid_flags() -> [atom()]. + +valid_flags() -> + [ + escaped_forward_slashes, + escaped_strings, + unescaped_jsonp, + dirty_strings, + multi_term, + return_tail, + repeat_keys, + strict, + stream, + uescape, + error_handler, + incomplete_handler + ]. + + +-spec extract_config(Config::proplists:proplist()) -> proplists:proplist(). + +extract_config(Config) -> + extract_parser_config(Config, []). + +extract_parser_config([], Acc) -> Acc; +extract_parser_config([{K,V}|Rest], Acc) -> + case lists:member(K, valid_flags()) of + true -> extract_parser_config(Rest, [{K,V}] ++ Acc) + ; false -> extract_parser_config(Rest, Acc) + end; +extract_parser_config([K|Rest], Acc) -> + case lists:member(K, valid_flags()) of + true -> extract_parser_config(Rest, [K] ++ Acc) + ; false -> extract_parser_config(Rest, Acc) + end. + + +%% eunit tests +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + + +config_test_() -> + [ + {"all flags", + ?_assertEqual( + #config{escaped_forward_slashes = true, + escaped_strings = true, + unescaped_jsonp = true, + dirty_strings = true, + multi_term = true, + return_tail = true, + strict_comments = true, + strict_commas = true, + strict_utf8 = true, + strict_single_quotes = true, + strict_escapes = true, + strict_control_codes = true, + stream = true, + uescape = true + }, + parse_config([dirty_strings, + escaped_forward_slashes, + escaped_strings, + unescaped_jsonp, + multi_term, + return_tail, + repeat_keys, + strict, + stream, + uescape + ]) + ) + }, + {"strict flag", + ?_assertEqual( + #config{strict_comments = true, + strict_commas = true, + strict_utf8 = true, + strict_single_quotes = true, + strict_escapes = true, + strict_control_codes = true + }, + parse_config([strict]) + ) + }, + {"strict selective", + ?_assertEqual( + #config{strict_comments = true}, + parse_config([{strict, [comments]}]) + ) + }, + {"strict expanded", + ?_assertEqual( + #config{strict_comments = true, + strict_utf8 = true, + strict_single_quotes = true, + strict_escapes = true + }, + parse_config([{strict, [comments, utf8, single_quotes, escapes]}]) + ) + }, + {"error_handler flag", ?_assertEqual( + #config{error_handler=fun ?MODULE:fake_error_handler/3}, + parse_config([{error_handler, fun ?MODULE:fake_error_handler/3}]) + )}, + {"two error_handlers defined", ?_assertError( + badarg, + parse_config([ + {error_handler, fun(_, _, _) -> true end}, + {error_handler, fun(_, _, _) -> false end} + ]) + )}, + {"incomplete_handler flag", ?_assertEqual( + #config{incomplete_handler=fun ?MODULE:fake_error_handler/3}, + parse_config([{incomplete_handler, fun ?MODULE:fake_error_handler/3}]) + )}, + {"two incomplete_handlers defined", ?_assertError( + badarg, + parse_config([ + {incomplete_handler, fun(_, _, _) -> true end}, + {incomplete_handler, fun(_, _, _) -> false end} + ]) + )}, + {"bad option flag", ?_assertError(badarg, parse_config([this_flag_does_not_exist]))} + ]. + + +config_to_list_test_() -> + [ + {"empty config", ?_assertEqual( + [], + config_to_list(#config{}) + )}, + {"all flags", ?_assertEqual( + [dirty_strings, + escaped_forward_slashes, + escaped_strings, + multi_term, + stream, + uescape, + unescaped_jsonp, + strict + ], + config_to_list( + #config{escaped_forward_slashes = true, + escaped_strings = true, + unescaped_jsonp = true, + dirty_strings = true, + multi_term = true, + strict_comments = true, + strict_utf8 = true, + strict_single_quotes = true, + strict_escapes = true, + strict_control_codes = true, + stream = true, + uescape = true + } + ) + )}, + {"single strict", ?_assertEqual( + [{strict, [comments]}], + config_to_list(#config{strict_comments = true}) + )}, + {"multiple strict", ?_assertEqual( + [{strict, [utf8, single_quotes, escapes]}], + config_to_list(#config{strict_utf8 = true, strict_single_quotes = true, strict_escapes = true}) + )}, + {"all strict", ?_assertEqual( + [strict], + config_to_list(#config{strict_comments = true, + strict_utf8 = true, + strict_single_quotes = true, + strict_escapes = true, + strict_control_codes = true}) + )}, + {"error handler", ?_assertEqual( + [{error_handler, fun ?MODULE:fake_error_handler/3}], + config_to_list(#config{error_handler=fun ?MODULE:fake_error_handler/3}) + )}, + {"incomplete handler", ?_assertEqual( + [{incomplete_handler, fun ?MODULE:fake_error_handler/3}], + config_to_list(#config{incomplete_handler=fun ?MODULE:fake_error_handler/3}) + )} + ]. + + +fake_error_handler(_, _, _) -> ok. + + +-endif. diff --git a/test/data/jsx/jsx_config.hrl b/test/data/jsx/jsx_config.hrl new file mode 100644 index 0000000..c89963c --- /dev/null +++ b/test/data/jsx/jsx_config.hrl @@ -0,0 +1,18 @@ +-record(config, { + dirty_strings = false :: boolean(), + escaped_forward_slashes = false :: boolean(), + escaped_strings = false :: boolean(), + multi_term = false :: boolean(), + strict_comments = false :: boolean(), + strict_commas = false :: boolean(), + strict_utf8 = false :: boolean(), + strict_single_quotes = false :: boolean(), + strict_escapes = false :: boolean(), + strict_control_codes = false :: boolean(), + stream = false :: boolean(), + return_tail = false :: boolean(), + uescape = false :: boolean(), + unescaped_jsonp = false :: boolean(), + error_handler = false :: false | jsx_config:handler(), + incomplete_handler = false :: false | jsx_config:handler() +}). diff --git a/test/data/jsx/jsx_consult.core b/test/data/jsx/jsx_consult.core new file mode 100644 index 0000000..8decdbc --- /dev/null +++ b/test/data/jsx/jsx_consult.core @@ -0,0 +1,175 @@ +module 'jsx_consult' ['consult'/2, + 'handle_event'/2, + 'init'/1, + 'module_info'/0, + 'module_info'/1, + 'reset'/1] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[99|[111|[110|[115|[117|[108|[116|[46|[101|[114|[108]]]]]]]]]]]]]]],1}], + %% Line 30 + 'record' = + %% Line 30 + [{'config',[{'record_field',31,{'atom',31,'labels'},{'atom',31,'binary'}}|[{'record_field',32,{'atom',32,'return_maps'},{'atom',32,'false'}}]]}], + %% Line 35 + 'type' = + %% Line 35 + [{'config',{'type',35,'list',[]},[]}], + %% Line 36 + 'export_type' = + %% Line 36 + [{'config',0}], + %% Line 39 + 'type' = + %% Line 39 + [{'json_value',{'type',39,'union',[{'type',39,'list',[{'user_type',39,'json_value',[]}]}|[{'type',40,'list',[{'type',40,'tuple',[{'type',40,'union',[{'type',40,'binary',[]}|[{'type',40,'atom',[]}]]}|[{'user_type',40,'json_value',[]}]]}]}|[{'atom',41,'true'}|[{'atom',42,'false'}|[{'atom',43,'null'}|[{'type',44,'integer',[]}|[{'type',45,'float',[]}|[{'type',46,'binary',[]}]]]]]]]]},[]}], + %% Line 68 + 'spec' = + %% Line 68 + [{{'consult',2},[{'type',68,'fun',[{'type',68,'product',[{'ann_type',68,[{'var',68,'File'}|[{'remote_type',68,[{'atom',68,'file'}|[{'atom',68,'name_all'}|[[]]]]}]]}|[{'ann_type',68,[{'var',68,'Config'}|[{'user_type',68,'config',[]}]]}]]}|[{'type',68,'list',[{'user_type',68,'json_value',[]}]}]]}]}], + %% Line 83 + 'type' = + %% Line 83 + [{'state',{'type',83,'tuple',[{'type',83,'nil',[]}|[{'remote_type',83,[{'atom',83,'proplists'}|[{'atom',83,'proplist'}|[[]]]]}|[{'type',83,'tuple',[{'type',83,'list',[]}|[{'type',83,'record',[{'atom',83,'config'}]}]]}]]]},[]}], + %% Line 84 + 'spec' = + %% Line 84 + [{{'init',1},[{'type',84,'fun',[{'type',84,'product',[{'ann_type',84,[{'var',84,'Config'}|[{'remote_type',84,[{'atom',84,'proplists'}|[{'atom',84,'proplist'}|[[]]]]}]]}]}|[{'user_type',84,'state',[]}]]}]}], + %% Line 89 + 'spec' = + %% Line 89 + [{{'reset',1},[{'type',89,'fun',[{'type',89,'product',[{'ann_type',89,[{'var',89,'State'}|[{'user_type',89,'state',[]}]]}]}|[{'user_type',89,'state',[]}]]}]}], + %% Line 94 + 'spec' = + %% Line 94 + [{{'handle_event',2},[{'type',94,'fun',[{'type',94,'product',[{'ann_type',94,[{'var',94,'Event'}|[{'type',94,'any',[]}]]}|[{'ann_type',94,[{'var',94,'State'}|[{'user_type',94,'state',[]}]]}]]}|[{'user_type',94,'state',[]}]]}]}]] +'opts'/1 = + %% Line 65 + fun (_0) -> + ['multi_term'|_0] +'consult'/2 = + %% Line 70 + fun (_0,_1) -> + case <_0,_1> of + + when call 'erlang':'is_list' + (Config) -> + %% Line 71 + case call 'file':'read_file' + (File) of + %% Line 72 + <{'ok',Bin}> when 'true' -> + let <_4> = + apply %% Line 75 + 'opts'/1 + (%% Line 75 + Config) + in let <_2> = + apply %% Line 76 + 'opts'/1 + (%% Line 76 + Config) + in let <_3> = + call %% Line 76 + 'jsx_config':%% Line 76 + 'extract_config' + (_2) + in let <_5> = + call %% Line 73 + 'jsx':%% Line 73 + 'decoder' + (%% Line 74 + 'jsx_consult', _4, _3) + in %% Line 73 + case apply _5 + (%% Line 77 + Bin) of + <{Final,_10,_11}> when 'true' -> + %% Line 78 + call 'lists':'reverse' + (Final) + ( <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + -| ['compiler_generated'] ) + end + %% Line 79 + <{'error',_12}> when 'true' -> + call 'erlang':'error' + ('badarg') + ( <_7> when 'true' -> + primop 'match_fail' + ({'case_clause',_7}) + -| ['compiler_generated'] ) + end + ( <_9,_8> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_9,_8}) + -| [{'function_name',{'consult',2}}] ) + -| ['compiler_generated'] ) + end +'init'/1 = + %% Line 86 + fun (_0) -> + let <_1> = + call 'jsx_to_term':'start_term' + (_0) + in {[],_0,_1} +'reset'/1 = + %% Line 91 + fun (_0) -> + case _0 of + <{Acc,Config,_3}> when 'true' -> + let <_1> = + call 'jsx_to_term':'start_term' + (Config) + in {Acc,Config,_1} + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'reset',1}}] ) + -| ['compiler_generated'] ) + end +'handle_event'/2 = + %% Line 96 + fun (_0,_1) -> + case <_0,_1> of + <'end_json',{Acc,Config,State}> when 'true' -> + let <_2> = + call %% Line 97 + 'jsx_to_term':%% Line 97 + 'get_value' + (%% Line 97 + State) + in let <_3> = + [_2|%% Line 97 + Acc] + in %% Line 97 + {_3,Config,State} + %% Line 98 + when 'true' -> + let <_4> = + call %% Line 99 + 'jsx_to_term':%% Line 99 + 'handle_event' + (%% Line 99 + Event, %% Line 99 + State) + in %% Line 99 + {Acc,Config,_4} + ( <_6,_5> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5}) + -| [{'function_name',{'handle_event',2}}] ) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('jsx_consult') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('jsx_consult', _0) +end \ No newline at end of file diff --git a/test/data/jsx/jsx_consult.erl b/test/data/jsx/jsx_consult.erl new file mode 100644 index 0000000..b1a4424 --- /dev/null +++ b/test/data/jsx/jsx_consult.erl @@ -0,0 +1,99 @@ +%% The MIT License + +%% Copyright (c) 2010-2015 Alisdair Sullivan + +%% Permission is hereby granted, free of charge, to any person obtaining a copy +%% of this software and associated documentation files (the "Software"), to deal +%% in the Software without restriction, including without limitation the rights +%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%% copies of the Software, and to permit persons to whom the Software is +%% furnished to do so, subject to the following conditions: + +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. + +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +%% THE SOFTWARE. + + +-module(jsx_consult). + +-export([consult/2]). +-export([init/1, reset/1, handle_event/2]). + + +-record(config, { + labels = binary, + return_maps = false +}). + +-type config() :: list(). +-export_type([config/0]). + +-ifndef(maps_support). +-type json_value() :: list(json_value()) + | list({binary() | atom(), json_value()}) + | true + | false + | null + | integer() + | float() + | binary(). +-endif. + +-ifdef(maps_support). +-type json_value() :: list(json_value()) + | map() + | true + | false + | null + | integer() + | float() + | binary(). +-endif. + + +-ifdef(maps_always). +opts(Opts) -> [return_maps, multi_term] ++ Opts. +-endif. +-ifndef(maps_always). +opts(Opts) -> [multi_term] ++ Opts. +-endif. + +-spec consult(File::file:name_all(), Config::config()) -> [json_value()]. + +consult(File, Config) when is_list(Config) -> + case file:read_file(File) of + {ok, Bin} -> + {Final, _, _} = (jsx:decoder( + ?MODULE, + opts(Config), + jsx_config:extract_config(opts(Config)) + ))(Bin), + lists:reverse(Final); + {error, _} -> erlang:error(badarg) + end. + + +-type state() :: {[], proplists:proplist(), {list(), #config{}}}. +-spec init(Config::proplists:proplist()) -> state(). + +init(Config) -> {[], Config, jsx_to_term:start_term(Config)}. + + +-spec reset(State::state()) -> state(). + +reset({Acc, Config, _}) -> {Acc, Config, jsx_to_term:start_term(Config)}. + + +-spec handle_event(Event::any(), State::state()) -> state(). + +handle_event(end_json, {Acc, Config, State}) -> + {[jsx_to_term:get_value(State)] ++ Acc, Config, State}; +handle_event(Event, {Acc, Config, State}) -> + {Acc, Config, jsx_to_term:handle_event(Event, State)}. diff --git a/test/data/jsx/jsx_decoder.core b/test/data/jsx/jsx_decoder.core new file mode 100644 index 0000000..2d05594 --- /dev/null +++ b/test/data/jsx/jsx_decoder.core @@ -0,0 +1,9318 @@ +module 'jsx_decoder' ['decoder'/3, + 'module_info'/0, + 'module_info'/1, + 'resume'/6] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[100|[101|[99|[111|[100|[101|[114|[46|[101|[114|[108]]]]]]]]]]]]]]],1}], + %% Line 27 + 'compile' = + %% Line 27 + [{'inline',[{'handle_event',3}]}], + %% Line 28 + 'compile' = + %% Line 28 + [{'inline',[{'format_number',1}]}], + %% Line 29 + 'compile' = + %% Line 29 + [{'inline',[{'maybe_replace',2}]}], + %% Line 30 + 'compile' = + %% Line 30 + [{'inline',[{'doublequote',5}|[{'singlequote',5}]]}], + %% Line 35 + 'spec' = + %% Line 35 + [{{'decoder',3},[{'type',35,'fun',[{'type',35,'product',[{'ann_type',35,[{'var',35,'Handler'}|[{'type',35,'module',[]}]]}|[{'ann_type',35,[{'var',35,'State'}|[{'type',35,'any',[]}]]}|[{'ann_type',35,[{'var',35,'Config'}|[{'type',35,'list',[]}]]}]]]}|[{'remote_type',35,[{'atom',35,'jsx'}|[{'atom',35,'decoder'}|[[]]]]}]]}]}], + %% Line 43 + 'spec' = + %% Line 43 + [{{'resume',6},[{'type',43,'fun',[{'type',43,'product',[{'ann_type',44,[{'var',44,'Rest'}|[{'type',44,'binary',[]}]]}|[{'ann_type',45,[{'var',45,'State'}|[{'type',45,'atom',[]}]]}|[{'ann_type',46,[{'var',46,'Handler'}|[{'type',46,'module',[]}]]}|[{'ann_type',47,[{'var',47,'Acc'}|[{'type',47,'any',[]}]]}|[{'ann_type',48,[{'var',48,'Stack'}|[{'type',48,'list',[{'type',48,'atom',[]}]}]]}|[{'ann_type',49,[{'var',49,'Config'}|[{'remote_type',49,[{'atom',49,'jsx'}|[{'atom',49,'config'}|[[]]]]}]]}]]]]]]}|[{'type',50,'union',[{'remote_type',50,[{'atom',50,'jsx'}|[{'atom',50,'decoder'}|[[]]]]}|[{'type',50,'tuple',[{'atom',50,'incomplete'}|[{'remote_type',50,[{'atom',50,'jsx'}|[{'atom',50,'decoder'}|[[]]]]}]]}]]}]]}]}], + %% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[99|[111|[110|[102|[105|[103|[46|[104|[114|[108]]]]]]]]]]]]]],1}], + %% Line 1 + 'record' = + %% Line 1 + [{'config',[{'typed_record_field',{'record_field',2,{'atom',2,'dirty_strings'},{'atom',2,'false'}},{'type',2,'boolean',[]}}|[{'typed_record_field',{'record_field',3,{'atom',3,'escaped_forward_slashes'},{'atom',3,'false'}},{'type',3,'boolean',[]}}|[{'typed_record_field',{'record_field',4,{'atom',4,'escaped_strings'},{'atom',4,'false'}},{'type',4,'boolean',[]}}|[{'typed_record_field',{'record_field',5,{'atom',5,'multi_term'},{'atom',5,'false'}},{'type',5,'boolean',[]}}|[{'typed_record_field',{'record_field',6,{'atom',6,'strict_comments'},{'atom',6,'false'}},{'type',6,'boolean',[]}}|[{'typed_record_field',{'record_field',7,{'atom',7,'strict_commas'},{'atom',7,'false'}},{'type',7,'boolean',[]}}|[{'typed_record_field',{'record_field',8,{'atom',8,'strict_utf8'},{'atom',8,'false'}},{'type',8,'boolean',[]}}|[{'typed_record_field',{'record_field',9,{'atom',9,'strict_single_quotes'},{'atom',9,'false'}},{'type',9,'boolean',[]}}|[{'typed_record_field',{'record_field',10,{'atom',10,'strict_escapes'},{'atom',10,'false'}},{'type',10,'boolean',[]}}|[{'typed_record_field',{'record_field',11,{'atom',11,'strict_control_codes'},{'atom',11,'false'}},{'type',11,'boolean',[]}}|[{'typed_record_field',{'record_field',12,{'atom',12,'stream'},{'atom',12,'false'}},{'type',12,'boolean',[]}}|[{'typed_record_field',{'record_field',13,{'atom',13,'return_tail'},{'atom',13,'false'}},{'type',13,'boolean',[]}}|[{'typed_record_field',{'record_field',14,{'atom',14,'uescape'},{'atom',14,'false'}},{'type',14,'boolean',[]}}|[{'typed_record_field',{'record_field',15,{'atom',15,'unescaped_jsonp'},{'atom',15,'false'}},{'type',15,'boolean',[]}}|[{'typed_record_field',{'record_field',16,{'atom',16,'error_handler'},{'atom',16,'false'}},{'type',16,'union',[{'atom',16,'false'}|[{'remote_type',16,[{'atom',16,'jsx_config'}|[{'atom',16,'handler'}|[[]]]]}]]}}|[{'typed_record_field',{'record_field',17,{'atom',17,'incomplete_handler'},{'atom',17,'false'}},{'type',17,'union',[{'atom',17,'false'}|[{'remote_type',17,[{'atom',17,'jsx_config'}|[{'atom',17,'handler'}|[[]]]]}]]}}]]]]]]]]]]]]]]]]}], + %% Line 72 + 'file' = + %% Line 72 + [{[106|[115|[120|[95|[100|[101|[99|[111|[100|[101|[114|[46|[101|[114|[108]]]]]]]]]]]]]]],72}]] +'decoder'/3 = + %% Line 37 + fun (_0,_1,_2) -> + %% Line 38 + ( fun (_5) -> + let <_4> = + call _0:'init' + (_1) + in let <_3> = + call 'jsx_config':'parse_config' + (_2) + in apply 'start'/4 + (_5, {_0,_4}, [], _3) + -| [{'id',{0,0,'-decoder/3-fun-0-'}}] ) +'resume'/6 = + %% Line 52 + fun (_0,_1,_2,_3,_4,_5) -> + %% Line 53 + case _1 of + %% Line 54 + <'start'> when 'true' -> + apply 'start'/4 + (_0, _2, _4, _5) + %% Line 55 + <'value'> when 'true' -> + apply 'value'/4 + (_0, _2, _4, _5) + %% Line 56 + <'object'> when 'true' -> + apply 'object'/4 + (_0, _2, _4, _5) + %% Line 57 + <'array'> when 'true' -> + apply 'array'/4 + (_0, _2, _4, _5) + %% Line 58 + <'colon'> when 'true' -> + apply 'colon'/4 + (_0, _2, _4, _5) + %% Line 59 + <'key'> when 'true' -> + apply 'key'/4 + (_0, _2, _4, _5) + %% Line 60 + <'string'> when 'true' -> + apply 'string'/5 + (_0, _2, _3, _4, _5) + %% Line 61 + <'number'> when 'true' -> + apply 'number'/5 + (_0, _2, _3, _4, _5) + %% Line 62 + <'true'> when 'true' -> + apply 'true'/4 + (_0, _2, _4, _5) + %% Line 63 + <'false'> when 'true' -> + apply 'false'/4 + (_0, _2, _4, _5) + %% Line 64 + <'null'> when 'true' -> + apply 'null'/4 + (_0, _2, _4, _5) + %% Line 65 + <'comment'> when 'true' -> + apply 'comment'/5 + (_0, _2, _3, _4, _5) + %% Line 66 + <'maybe_done'> when 'true' -> + apply 'maybe_done'/4 + (_0, _2, _4, _5) + %% Line 67 + <'done'> when 'true' -> + apply 'done'/4 + (_0, _2, _4, _5) + ( <_6> when 'true' -> + primop 'match_fail' + ({'case_clause',_6}) + -| ['compiler_generated'] ) + end +'incomplete'/5 = + %% Line 134 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + when 'true' -> + %% Line 135 + ( case Config of + ( <( {'config',_29,_30,_31,_32,_33,_34,_35,_36,_37,_38,_39,_40,_41,_42,_rec0,_43} + -| ['compiler_generated'] )> when 'true' -> + case _rec0 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_7> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Rest, {'decoder',State,Handler,'null',Stack}, _7) + end + -| ['compiler_generated'] ) + ( <_44> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 136 + when 'true' -> + %% Line 137 + apply 'incomplete'/6 + (State, Rest, Handler, 'unused', Stack, Config) + end +'incomplete'/6 = + %% Line 140 + fun (_0,_1,_2,_3,_4,_5) -> + case <_0,_1,_2,_3,_4,_5> of + when 'true' -> + %% Line 141 + ( case Config of + ( <( {'config',_47,_48,_49,_50,_51,_52,_53,_54,_55,_56,_57,_58,_59,_60,_rec1,_61} + -| ['compiler_generated'] )> when 'true' -> + case _rec1 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_8> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Rest, {'decoder',State,Handler,Acc,Stack}, _8) + end + -| ['compiler_generated'] ) + ( <_62> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 142 + when 'true' -> + let <_24> = + fun (_22) -> + %% Line 143 + case _22 of + + when call 'erlang':'is_binary' + (_22) -> + let <_10> = + #{#<%% Line 144 + Rest>(%% Line 144 + 'all',8,'binary',['unsigned'|['big']]), + #<%% Line 144 + Stream>(%% Line 144 + 'all',8,'binary',['unsigned'|['big']])}# + in %% Line 144 + apply 'resume'/6 + (_10, State, Handler, Acc, Stack, Config) + %% Line 145 + + when let <_11> = + call 'erlang':'=:=' + (_22, 'end_stream') + in let <_12> = + call 'erlang':'=:=' + (_22, 'end_json') + in call 'erlang':'or' + (_11, _12) -> + let <_16> = + #{#<%% Line 146 + Rest>(%% Line 146 + 'all',8,'binary',['unsigned'|['big']]), + %% Line 146 + #<32>(8,1,'integer',['unsigned'|['big']])}# + in %% Line 146 + case Config of + <{'config',_78,_79,_80,_81,_82,_83,_84,_85,_86,_87,_88,_89,_90,_91,_92,_93}> when 'true' -> + let <_15> = + call 'erlang':'setelement' + (12, Config, 'false') + in case apply 'resume'/6 + (_16, State, Handler, Acc, Stack, _15) of + %% Line 147 + <{'incomplete',_95}> when 'true' -> + ( case Config of + ( <( {'config',_96,_97,_98,_99,_100,_101,_102,_103,_104,_105,_106,_107,_108,_109,_rec3,_110} + -| ['compiler_generated'] )> when 'true' -> + case _rec3 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_19> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Rest, {'decoder',State,Handler,Acc,Stack}, _19) + end + -| ['compiler_generated'] ) + ( <_111> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 148 + when 'true' -> + Else + end + ( <_94> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + ( <_23> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_23}) + -| [{'function_name',{'-incomplete/6-fun-0-',1}}] ) + -| ['compiler_generated'] ) + end + in %% Line 143 + {'incomplete',_24} + %% Line 152 + when 'true' -> + let <_25> = + call %% Line 153 + 'jsx_config':%% Line 153 + 'config_to_list' + (%% Line 153 + Config) + in %% Line 153 + apply F + (Rest, {'decoder',State,Handler,Acc,Stack}, _25) + ( <_31,_30,_29,_28,_27,_26> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_31,_30,_29,_28,_27,_26}) + -| [{'function_name',{'incomplete',6}}] ) + -| ['compiler_generated'] ) + end +'handle_event'/3 = + %% Line 156 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + let <_3> = + call Handler:'handle_event' + (Event, State) + in {Handler,_3} + ( <_6,_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5,_4}) + -| [{'function_name',{'handle_event',3}}] ) + -| ['compiler_generated'] ) + end +'start'/4 = + %% Line 159 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<187>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 160 + apply 'value'/4 + (Rest, Handler, Stack, Config) + %% Line 161 + <#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<187>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 162 + apply 'incomplete'/5 + ('start', #{#<239>(8,1,'integer',['unsigned'|['big']]), + #<187>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 163 + <#{#<239>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 164 + apply 'incomplete'/5 + ('start', #{#<239>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 165 + <#{}#,Handler,Stack,Config> when 'true' -> + %% Line 166 + apply 'incomplete'/5 + ('start', #{}#, Handler, Stack, Config) + %% Line 167 + when 'true' -> + %% Line 168 + apply 'value'/4 + (Bin, Handler, Stack, Config) + end +'value'/4 = + %% Line 171 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#<34>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 172 + apply 'string'/4 + (Rest, Handler, Stack, Config) + %% Line 173 + <#{#<32>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 174 + apply 'value'/4 + (Rest, Handler, Stack, Config) + %% Line 175 + <#{#<123>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + ( case %% Line 176 + of + ( <( {_103,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_104> = + call _103:( 'handle_event' + -| ['compiler_generated'] ) + (( 'start_object' + -| ['compiler_generated'] ), State) + in let <_4> = {_103,_104} + in %% Line 176 + apply 'object'/4 + (Rest, _4, ['key'|Stack], Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( 'start_object' + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 177 + <#{#<91>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + ( case %% Line 178 + of + ( <( {_108,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_109> = + call _108:( 'handle_event' + -| ['compiler_generated'] ) + (( 'start_array' + -| ['compiler_generated'] ), State) + in let <_5> = {_108,_109} + in %% Line 178 + apply 'array'/4 + (Rest, _5, ['array'|Stack], Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( 'start_array' + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 179 + <#{#<116>(8,1,'integer',['unsigned'|['big']]), + #<114>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']]), + #<101>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + ( case %% Line 180 + of + ( <( {_113,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_114> = + call _113:( 'handle_event' + -| ['compiler_generated'] ) + (( {'literal','true'} + -| ['compiler_generated'] ), State) + in let <_6> = {_113,_114} + in %% Line 180 + apply 'maybe_done'/4 + (Rest, _6, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( {'literal','true'} + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 181 + <#{#<102>(8,1,'integer',['unsigned'|['big']]), + #<97>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']]), + #<115>(8,1,'integer',['unsigned'|['big']]), + #<101>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + ( case %% Line 182 + of + ( <( {_118,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_119> = + call _118:( 'handle_event' + -| ['compiler_generated'] ) + (( {'literal','false'} + -| ['compiler_generated'] ), State) + in let <_7> = {_118,_119} + in %% Line 182 + apply 'maybe_done'/4 + (Rest, _7, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( {'literal','false'} + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 183 + <#{#<110>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + ( case %% Line 184 + of + ( <( {_123,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_124> = + call _123:( 'handle_event' + -| ['compiler_generated'] ) + (( {'literal','null'} + -| ['compiler_generated'] ), State) + in let <_8> = {_123,_124} + in %% Line 184 + apply 'maybe_done'/4 + (Rest, _8, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( {'literal','null'} + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 185 + <#{#<48>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 186 + apply 'number'/5 + (Rest, Handler, [48], ['zero'|Stack], Config) + %% Line 187 + <#{#<49>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 188 + apply 'number'/5 + (Rest, Handler, [49], ['integer'|Stack], Config) + %% Line 189 + <#{#<50>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 190 + apply 'number'/5 + (Rest, Handler, [50], ['integer'|Stack], Config) + %% Line 191 + <#{#<51>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 192 + apply 'number'/5 + (Rest, Handler, [51], ['integer'|Stack], Config) + %% Line 193 + <#{#<52>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 194 + apply 'number'/5 + (Rest, Handler, [52], ['integer'|Stack], Config) + %% Line 195 + <#{#<53>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 196 + apply 'number'/5 + (Rest, Handler, [53], ['integer'|Stack], Config) + %% Line 197 + <#{#<54>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 198 + apply 'number'/5 + (Rest, Handler, [54], ['integer'|Stack], Config) + %% Line 199 + <#{#<55>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 200 + apply 'number'/5 + (Rest, Handler, [55], ['integer'|Stack], Config) + %% Line 201 + <#{#<56>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 202 + apply 'number'/5 + (Rest, Handler, [56], ['integer'|Stack], Config) + %% Line 203 + <#{#<57>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 204 + apply 'number'/5 + (Rest, Handler, [57], ['integer'|Stack], Config) + %% Line 205 + <#{#<45>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 206 + apply 'number'/5 + (Rest, Handler, [45], ['negative'|Stack], Config) + %% Line 207 + <#{#<10>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 208 + apply 'value'/4 + (Rest, Handler, Stack, Config) + %% Line 209 + <#{#<116>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 210 + apply 'true'/4 + (Rest, Handler, Stack, Config) + %% Line 211 + <#{#<102>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 212 + apply 'false'/4 + (Rest, Handler, Stack, Config) + %% Line 213 + <#{#<110>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 214 + apply 'null'/4 + (Rest, Handler, Stack, Config) + %% Line 215 + <#{#<9>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 216 + apply 'value'/4 + (Rest, Handler, Stack, Config) + %% Line 217 + <#{#<13>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 218 + apply 'value'/4 + (Rest, Handler, Stack, Config) + %% Line 219 + <#{#<39>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_22,_23,_24,_25,_26,_27,_28,'false',_29,_30,_31,_32,_33,_34,_35,_36}> when 'true' -> + %% Line 220 + apply 'string'/4 + (Rest, Handler, ['singlequote'|Stack], Config) + %% Line 221 + (8,1,'integer',['unsigned'|['big']]), + #<_37>('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_38,_39,_40,_41,_42,'false',_43,_44,_45,_46,_47,_48,_49,_50,_51,_52}> when 'true' -> + %% Line 222 + apply 'maybe_done'/4 + (Rest, Handler, Stack, Config) + %% Line 223 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_53,_54,_55,_56,'true',_57,_58,_59,_60,_61,_62,_63,_64,_65,_66,_67}> when 'true' -> + %% Line 224 + ( case Config of + ( <( {'config',_68,_69,_70,_71,_72,_73,_74,_75,_76,_77,_78,_79,_80,_81,_rec4,_82} + -| ['compiler_generated'] )> when 'true' -> + case _rec4 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_12> = + #{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}# + in let <_11> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (_12, {'decoder','value',Handler,'null',Stack}, _11) + end + -| ['compiler_generated'] ) + ( <_83> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 225 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 226 + apply 'comment'/5 + (Rest, Handler, 'value', ['comment'|Stack], Config) + %% Line 227 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<42>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 228 + apply 'comment'/5 + (Rest, Handler, 'value', ['multicomment'|Stack], Config) + %% Line 229 + <#{#<47>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 230 + apply 'incomplete'/5 + ('value', #{#<47>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 231 + <#{}#,Handler,Stack,Config> when 'true' -> + %% Line 232 + apply 'incomplete'/5 + ('value', #{}#, Handler, Stack, Config) + %% Line 233 + when 'true' -> + %% Line 234 + ( case Config of + ( <( {'config',_84,_85,_86,_87,_88,_89,_90,_91,_92,_93,_94,_95,_96,_97,_rec5,_98} + -| ['compiler_generated'] )> when 'true' -> + case _rec5 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_16> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','value',Handler,'null',Stack}, _16) + end + -| ['compiler_generated'] ) + ( <_99> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'object'/4 = + %% Line 237 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#<34>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 238 + apply 'string'/4 + (Rest, Handler, Stack, Config) + %% Line 239 + <#{#<32>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 240 + apply 'object'/4 + (Rest, Handler, Stack, Config) + %% Line 241 + <#{#<125>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,['key'|Stack],Config> when 'true' -> + ( case %% Line 242 + of + ( <( {_83,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_84> = + call _83:( 'handle_event' + -| ['compiler_generated'] ) + (( 'end_object' + -| ['compiler_generated'] ), State) + in let <_4> = {_83,_84} + in %% Line 242 + apply 'maybe_done'/4 + (Rest, _4, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( 'end_object' + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 243 + <#{#<10>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 244 + apply 'object'/4 + (Rest, Handler, Stack, Config) + %% Line 245 + <#{#<9>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 246 + apply 'object'/4 + (Rest, Handler, Stack, Config) + %% Line 247 + <#{#<13>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 248 + apply 'object'/4 + (Rest, Handler, Stack, Config) + %% Line 249 + <#{#<39>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_18,_19,_20,_21,_22,_23,_24,'false',_25,_26,_27,_28,_29,_30,_31,_32}> when 'true' -> + %% Line 250 + apply 'string'/4 + (Rest, Handler, ['singlequote'|Stack], Config) + %% Line 251 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_33,_34,_35,_36,'true',_37,_38,_39,_40,_41,_42,_43,_44,_45,_46,_47}> when 'true' -> + %% Line 252 + ( case Config of + ( <( {'config',_48,_49,_50,_51,_52,_53,_54,_55,_56,_57,_58,_59,_60,_61,_rec6,_62} + -| ['compiler_generated'] )> when 'true' -> + case _rec6 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_8> = + #{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}# + in let <_7> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (_8, {'decoder','object',Handler,'null',Stack}, _7) + end + -| ['compiler_generated'] ) + ( <_63> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 253 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 254 + apply 'comment'/5 + (Rest, Handler, 'object', ['comment'|Stack], Config) + %% Line 255 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<42>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 256 + apply 'comment'/5 + (Rest, Handler, 'object', ['multicomment'|Stack], Config) + %% Line 257 + <#{#<47>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 258 + apply 'incomplete'/5 + ('object', #{#<47>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 259 + <#{}#,Handler,Stack,Config> when 'true' -> + %% Line 260 + apply 'incomplete'/5 + ('object', #{}#, Handler, Stack, Config) + %% Line 261 + when 'true' -> + %% Line 262 + ( case Config of + ( <( {'config',_64,_65,_66,_67,_68,_69,_70,_71,_72,_73,_74,_75,_76,_77,_rec7,_78} + -| ['compiler_generated'] )> when 'true' -> + case _rec7 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_12> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','object',Handler,'null',Stack}, _12) + end + -| ['compiler_generated'] ) + ( <_79> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'array'/4 = + %% Line 265 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#<93>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,['array'|Stack],Config> when 'true' -> + ( case %% Line 266 + of + ( <( {_28,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_29> = + call _28:( 'handle_event' + -| ['compiler_generated'] ) + (( 'end_array' + -| ['compiler_generated'] ), State) + in let <_4> = {_28,_29} + in %% Line 266 + apply 'maybe_done'/4 + (Rest, _4, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( 'end_array' + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 267 + <#{#<32>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 268 + apply 'array'/4 + (Rest, Handler, Stack, Config) + %% Line 269 + <#{#<10>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 270 + apply 'array'/4 + (Rest, Handler, Stack, Config) + %% Line 271 + <#{#<9>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 272 + apply 'array'/4 + (Rest, Handler, Stack, Config) + %% Line 273 + <#{#<13>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 274 + apply 'array'/4 + (Rest, Handler, Stack, Config) + %% Line 275 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_10,_11,_12,_13,'true',_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24}> when 'true' -> + let <_5> = + #{#<%% Line 276 + 47>(%% Line 276 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 276 + Rest>(%% Line 276 + 'all',8,'binary',['unsigned'|['big']])}# + in %% Line 276 + apply 'value'/4 + (_5, Handler, Stack, Config) + %% Line 277 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 278 + apply 'comment'/5 + (Rest, Handler, 'array', ['comment'|Stack], Config) + %% Line 279 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<42>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 280 + apply 'comment'/5 + (Rest, Handler, 'array', ['multicomment'|Stack], Config) + %% Line 281 + <#{#<47>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 282 + apply 'incomplete'/5 + ('array', #{#<47>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 283 + <#{}#,Handler,Stack,Config> when 'true' -> + %% Line 284 + apply 'incomplete'/5 + ('array', #{}#, Handler, Stack, Config) + %% Line 285 + when 'true' -> + %% Line 286 + apply 'value'/4 + (Bin, Handler, Stack, Config) + end +'colon'/4 = + %% Line 289 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#<58>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,['key'|Stack],Config> when 'true' -> + %% Line 290 + apply 'value'/4 + (Rest, Handler, ['object'|Stack], Config) + %% Line 291 + <#{#<32>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 292 + apply 'colon'/4 + (Rest, Handler, Stack, Config) + %% Line 293 + <#{#<10>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 294 + apply 'colon'/4 + (Rest, Handler, Stack, Config) + %% Line 295 + <#{#<9>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 296 + apply 'colon'/4 + (Rest, Handler, Stack, Config) + %% Line 297 + <#{#<13>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 298 + apply 'colon'/4 + (Rest, Handler, Stack, Config) + %% Line 299 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_17,_18,_19,_20,'true',_21,_22,_23,_24,_25,_26,_27,_28,_29,_30,_31}> when 'true' -> + %% Line 300 + ( case Config of + ( <( {'config',_32,_33,_34,_35,_36,_37,_38,_39,_40,_41,_42,_43,_44,_45,_rec8,_46} + -| ['compiler_generated'] )> when 'true' -> + case _rec8 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_7> = + #{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}# + in let <_6> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (_7, {'decoder','colon',Handler,'null',Stack}, _6) + end + -| ['compiler_generated'] ) + ( <_47> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 301 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 302 + apply 'comment'/5 + (Rest, Handler, 'colon', ['comment'|Stack], Config) + %% Line 303 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<42>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 304 + apply 'comment'/5 + (Rest, Handler, 'colon', ['multicomment'|Stack], Config) + %% Line 305 + <#{#<47>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 306 + apply 'incomplete'/5 + ('colon', #{#<47>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 307 + <#{}#,Handler,Stack,Config> when 'true' -> + %% Line 308 + apply 'incomplete'/5 + ('colon', #{}#, Handler, Stack, Config) + %% Line 309 + when 'true' -> + %% Line 310 + ( case Config of + ( <( {'config',_48,_49,_50,_51,_52,_53,_54,_55,_56,_57,_58,_59,_60,_61,_rec9,_62} + -| ['compiler_generated'] )> when 'true' -> + case _rec9 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_11> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','colon',Handler,'null',Stack}, _11) + end + -| ['compiler_generated'] ) + ( <_63> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'key'/4 = + %% Line 313 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#<34>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 314 + apply 'string'/4 + (Rest, Handler, Stack, Config) + %% Line 315 + <#{#<32>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 316 + apply 'key'/4 + (Rest, Handler, Stack, Config) + %% Line 317 + <#{#<125>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,['key'|Stack],Config = {'config',_18,_19,_20,_21,_22,'false',_23,_24,_25,_26,_27,_28,_29,_30,_31,_32}> when 'true' -> + let <_4> = + #{#<%% Line 318 + 125>(%% Line 318 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 318 + Rest>(%% Line 318 + 'all',8,'binary',['unsigned'|['big']])}# + in %% Line 318 + apply 'maybe_done'/4 + (_4, Handler, ['object'|Stack], Config) + %% Line 319 + <#{#<10>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 320 + apply 'key'/4 + (Rest, Handler, Stack, Config) + %% Line 321 + <#{#<9>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 322 + apply 'key'/4 + (Rest, Handler, Stack, Config) + %% Line 323 + <#{#<13>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 324 + apply 'key'/4 + (Rest, Handler, Stack, Config) + %% Line 325 + <#{#<39>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_33,_34,_35,_36,_37,_38,_39,'false',_40,_41,_42,_43,_44,_45,_46,_47}> when 'true' -> + %% Line 326 + apply 'string'/4 + (Rest, Handler, ['singlequote'|Stack], Config) + %% Line 327 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_48,_49,_50,_51,'true',_52,_53,_54,_55,_56,_57,_58,_59,_60,_61,_62}> when 'true' -> + %% Line 328 + ( case Config of + ( <( {'config',_63,_64,_65,_66,_67,_68,_69,_70,_71,_72,_73,_74,_75,_76,_rec10,_77} + -| ['compiler_generated'] )> when 'true' -> + case _rec10 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_8> = + #{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}# + in let <_7> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (_8, {'decoder','key',Handler,'null',Stack}, _7) + end + -| ['compiler_generated'] ) + ( <_78> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 329 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 330 + apply 'comment'/5 + (Rest, Handler, 'key', ['comment'|Stack], Config) + %% Line 331 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<42>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 332 + apply 'comment'/5 + (Rest, Handler, 'key', ['multicomment'|Stack], Config) + %% Line 333 + <#{#<47>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 334 + apply 'incomplete'/5 + ('key', #{#<47>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 335 + <#{}#,Handler,Stack,Config> when 'true' -> + %% Line 336 + apply 'incomplete'/5 + ('key', #{}#, Handler, Stack, Config) + %% Line 337 + when 'true' -> + %% Line 338 + ( case Config of + ( <( {'config',_79,_80,_81,_82,_83,_84,_85,_86,_87,_88,_89,_90,_91,_92,_rec11,_93} + -| ['compiler_generated'] )> when 'true' -> + case _rec11 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_12> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','key',Handler,'null',Stack}, _12) + end + -| ['compiler_generated'] ) + ( <_94> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'string'/4 = + %% Line 343 + fun (_0,_1,_2,_3) -> + %% Line 344 + apply 'string'/5 + (_0, _1, [], _2, _3) +'string'/5 = + %% Line 347 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + <#{#<34>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + %% Line 624 + ( case of + ( <_214,_215,_216,( _217 = ( [( 'key' + -| ['compiler_generated'] )|_15] + -| ['compiler_generated'] ) + -| ['compiler_generated'] ),_218> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_5> = + call %% Line 625 + ( 'erlang' + -| ['compiler_generated'] ):%% Line 625 + ( 'iolist_to_binary' + -| ['compiler_generated'] ) + (_216) + in ( let <_219> = {%% Line 625 + ( 'key' + -| ['compiler_generated'] ),_5} + in ( case <_219,_215,_218> of + ( when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_223> = + call _222:( 'handle_event' + -| ['compiler_generated'] ) + (Event, State) + in ( let <_6> = {_222,_223} + in %% Line 625 + ( apply 'colon'/4 + (_214, _6, _217, _218) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_6,_224,_225> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),_6,_224,_225} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 626 + ( <_226,_227,_228,( _229 = ( [( 'singlequote' + -| ['compiler_generated'] )|_16] + -| ['compiler_generated'] ) + -| ['compiler_generated'] ),_230> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_7> = + apply %% Line 627 + 'maybe_replace'/2 + (%% Line 627 + ( 34 + -| ['compiler_generated'] ), _230) + in %% Line 627 + ( apply 'string'/5 + (_226, _227, ( [_228|( [_7|( [] + -| ['compiler_generated'] )] + -| ['compiler_generated'] )] + -| ['compiler_generated'] ), _229, _230) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 628 + ( <( #{}# + -| ['compiler_generated'] ),_231,_232,( _233 = ( [( 'singlequote' + -| ['compiler_generated'] )|_17] + -| ['compiler_generated'] ) + -| ['compiler_generated'] ),_234> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 629 + ( apply 'incomplete'/6 + (( 'string' + -| ['compiler_generated'] ), ( #{#<34>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ), _231, _232, _233, _234) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 630 + ( <_235,_236,_237,_238,_239> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_8> = + call %% Line 631 + ( 'erlang' + -| ['compiler_generated'] ):%% Line 631 + ( 'iolist_to_binary' + -| ['compiler_generated'] ) + (_237) + in ( let <_240> = {%% Line 631 + ( 'string' + -| ['compiler_generated'] ),_8} + in ( case <_240,_236,_239> of + ( when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_244> = + call _243:( 'handle_event' + -| ['compiler_generated'] ) + (Event, State) + in ( let <_9> = {_243,_244} + in %% Line 631 + ( apply 'maybe_done'/4 + (_235, _9, _238, _239) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_6,_5,_245> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),_6,_5,_245} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 349 + <#{#<39>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + %% Line 634 + ( case of + ( <_251,_252,_253,( [( 'singlequote' + -| ['compiler_generated'] )|( ( _@r0 + -| ['compiler_generated'] ) = ( [( 'key' + -| ['compiler_generated'] )|_254] + -| ['compiler_generated'] ) + -| ['compiler_generated'] )] + -| ['compiler_generated'] ),_255> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_5> = + call %% Line 635 + ( 'erlang' + -| ['compiler_generated'] ):%% Line 635 + ( 'iolist_to_binary' + -| ['compiler_generated'] ) + (_253) + in ( let <_256> = {%% Line 635 + ( 'key' + -| ['compiler_generated'] ),_5} + in ( case <_256,_252,_255> of + ( when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_260> = + call _259:( 'handle_event' + -| ['compiler_generated'] ) + (Event, State) + in ( let <_6> = {_259,_260} + in %% Line 635 + ( apply 'colon'/4 + (_251, _6, ( _@r0 + -| ['compiler_generated'] ), _255) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_6,_261,_262> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),_6,_261,_262} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 636 + ( <_263,_264,_265,( [( 'singlequote' + -| ['compiler_generated'] )|_266] + -| ['compiler_generated'] ),_267> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_7> = + call %% Line 637 + ( 'erlang' + -| ['compiler_generated'] ):%% Line 637 + ( 'iolist_to_binary' + -| ['compiler_generated'] ) + (_265) + in ( let <_268> = {%% Line 637 + ( 'string' + -| ['compiler_generated'] ),_7} + in ( case <_268,_264,_267> of + ( when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_272> = + call _271:( 'handle_event' + -| ['compiler_generated'] ) + (Event, State) + in ( let <_8> = {_271,_272} + in %% Line 637 + ( apply 'maybe_done'/4 + (_263, _8, _266, _267) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_6,_5,_273> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),_6,_5,_273} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 638 + ( <_274,_275,_276,_277,_278> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 639 + ( apply 'string'/5 + (_274, _275, ( [_276|( [39] + -| ['compiler_generated'] )] + -| ['compiler_generated'] ), _277, _278) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 351 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_5> = + case %% Line 352 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<47>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 753 + ( <( _281 = ( {( 'config' + -| ['compiler_generated'] ),_117,_118,( 'true' + -| ['compiler_generated'] ),_119,_120,_121,_122,_123,_124,_125,_126,_127,_128,_129,_130,_131} + -| ['compiler_generated'] ) + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 754 + ( case _281 of + ( <( {( 'config' + -| ['compiler_generated'] ),_132,_rec18,_133,_134,_135,_136,_137,_138,_139,_140,_141,_142,_143,_144,_145,_146} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( case _rec18 of + %% Line 755 + ( <( 'true' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 756 + ( <( 'false' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<47>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_283> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'case_clause' + -| ['compiler_generated'] ),_283} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_147> when ( 'true' + -| ['compiler_generated'] ) -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<47>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 352 + apply 'string'/5 + (Rest, Handler, [Acc|[_5|[]]], Stack, Config) + %% Line 353 + <#{#<92>('undefined','undefined','utf8',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + %% Line 354 + apply 'unescape'/5 + (Rest, Handler, Acc, Stack, Config) + %% Line 356 + ('undefined','undefined','utf8',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config',_34,_35,_36,_37,_38,_39,_40,_41,_42,_43,_44,_45,'true',_46,_47,_48}> when 'true' -> + %% Line 357 + case X of + %% Line 358 + <_49> + when call 'erlang':'<' + (X, + 128) -> + apply 'count'/5 + (Bin, Handler, Acc, Stack, Config) + %% Line 359 + <_52> when 'true' -> + let <_6> = + apply 'json_escape_sequence'/1 + (X) + in apply 'string'/5 + (Rest, Handler, [Acc|[_6|[]]], Stack, Config) + end + %% Line 362 + <#{#<226>(8,1,'integer',['unsigned'|['big']]), + #<128>(8,1,'integer',['unsigned'|['big']]), + #<168>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_8> = + case %% Line 363 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<40>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 759 + ( <( _292 = ( {( 'config' + -| ['compiler_generated'] ),_163,_164,( 'true' + -| ['compiler_generated'] ),_165,_166,_167,_168,_169,_170,_171,_172,_173,_174,_175,_176,_177} + -| ['compiler_generated'] ) + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 760 + ( case _292 of + ( <( {( 'config' + -| ['compiler_generated'] ),_178,_179,_180,_181,_182,_183,_184,_185,_186,_187,_188,_189,_190,_rec19,_191,_192} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( case _rec19 of + %% Line 761 + ( <( 'true' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<226>(8,1,'integer',['unsigned'|['big']]), + #<128>(8,1,'integer',['unsigned'|['big']]), + #<168>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 762 + ( <( 'false' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( apply 'json_escape_sequence'/1 + (( 8232 + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_9> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'case_clause' + -| ['compiler_generated'] ),_9} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_193> when ( 'true' + -| ['compiler_generated'] ) -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<226>(8,1,'integer',['unsigned'|['big']]), + #<128>(8,1,'integer',['unsigned'|['big']]), + #<168>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 363 + apply 'string'/5 + (Rest, Handler, [Acc|[_8|[]]], Stack, Config) + %% Line 365 + <#{#<226>(8,1,'integer',['unsigned'|['big']]), + #<128>(8,1,'integer',['unsigned'|['big']]), + #<169>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_9> = + case %% Line 366 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<41>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 759 + ( <( _299 = ( {( 'config' + -| ['compiler_generated'] ),_163,_164,( 'true' + -| ['compiler_generated'] ),_165,_166,_167,_168,_169,_170,_171,_172,_173,_174,_175,_176,_177} + -| ['compiler_generated'] ) + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 760 + ( case _299 of + ( <( {( 'config' + -| ['compiler_generated'] ),_178,_179,_180,_181,_182,_183,_184,_185,_186,_187,_188,_189,_190,_rec19,_191,_192} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( case _rec19 of + %% Line 761 + ( <( 'true' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<226>(8,1,'integer',['unsigned'|['big']]), + #<128>(8,1,'integer',['unsigned'|['big']]), + #<169>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 762 + ( <( 'false' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( apply 'json_escape_sequence'/1 + (( 8233 + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_9> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'case_clause' + -| ['compiler_generated'] ),_9} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_193> when ( 'true' + -| ['compiler_generated'] ) -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<226>(8,1,'integer',['unsigned'|['big']]), + #<128>(8,1,'integer',['unsigned'|['big']]), + #<169>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 366 + apply 'string'/5 + (Rest, Handler, [Acc|[_9|[]]], Stack, Config) + %% Line 367 + ('undefined','undefined','utf8',['unsigned'|['big']]), + #<_53>('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config',_54,_55,_56,_57,_58,_59,_60,_61,_62,'true',_63,_64,_65,_66,_67,_68}> + when call 'erlang':'>' + (X, + 31) -> + %% Line 368 + apply 'count'/5 + (Bin, Handler, Acc, Stack, Config) + %% Line 369 + ('undefined','undefined','utf8',['unsigned'|['big']]), + #<_70>('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config',_71,_72,_73,_74,_75,_76,_77,_78,_79,'false',_80,_81,_82,_83,_84,_85}> when 'true' -> + %% Line 370 + apply 'count'/5 + (Bin, Handler, Acc, Stack, Config) + %% Line 372 + <#{#(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config','true',_86,_87,_88,_89,_90,_91,_92,_93,_94,_95,_96,_97,_98,_99,_100}> when 'true' -> + %% Line 373 + apply 'string'/5 + (Rest, Handler, [Acc|[X|[]]], Stack, Config) + %% Line 375 + <#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<190>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + %% Line 376 + apply 'string'/5 + (Rest, Handler, [Acc|[#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<190>(8,1,'integer',['unsigned'|['big']])}#]], Stack, Config) + %% Line 377 + <#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + %% Line 378 + apply 'string'/5 + (Rest, Handler, [Acc|[#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']])}#]], Stack, Config) + %% Line 379 + <#{}#,Handler,Acc,Stack,Config> when 'true' -> + %% Line 380 + apply 'incomplete'/6 + ('string', #{}#, Handler, Acc, Stack, Config) + %% Line 381 + <#{#(8,1,'integer',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> + when call 'erlang':'>=' + (X, + 192) -> + let <_10> = + #{#<%% Line 382 + X>(%% Line 382 + 8,1,'integer',['unsigned'|['big']])}# + in %% Line 382 + apply 'incomplete'/6 + ('string', _10, Handler, Acc, Stack, Config) + %% Line 383 + <#{#(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> + when let <_11> = + call 'erlang':'>=' + (X, 224) + in let <_12> = + call 'erlang':'>=' + (Y, 128) + in call 'erlang':'and' + (_11, _12) -> + let <_13> = + #{#<%% Line 384 + X>(%% Line 384 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 384 + Y>(%% Line 384 + 8,1,'integer',['unsigned'|['big']])}# + in %% Line 384 + apply 'incomplete'/6 + ('string', _13, Handler, Acc, Stack, Config) + %% Line 385 + <#{#(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> + when %% Line 386 + try + let <_14> = + call 'erlang':'>=' + (X, 224) + in let <_15> = + call 'erlang':'>=' + (Y, 128) + in let <_16> = + call 'erlang':'>=' + (Z, 128) + in let <_17> = + call 'erlang':'and' + (_15, _16) + in call 'erlang':'and' + (_14, _17) + of -> + Try + catch -> + 'false' -> + let <_18> = + #{#<%% Line 387 + X>(%% Line 387 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 387 + Y>(%% Line 387 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 387 + Z>(%% Line 387 + 8,1,'integer',['unsigned'|['big']])}# + in %% Line 387 + apply 'incomplete'/6 + ('string', _18, Handler, Acc, Stack, Config) + %% Line 389 + <#{#<237>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #<_101>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config',_102,_103,_104,_105,_106,_107,'false',_108,_109,_110,_111,_112,_113,_114,_115,_116}> + when %% Line 390 + call 'erlang':'>=' + (X, + 160) -> + %% Line 391 + apply 'string'/5 + (Rest, Handler, [Acc|[#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<189>(8,1,'integer',['unsigned'|['big']])}#]], Stack, Config) + %% Line 393 + <#{#(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config',_117,_118,_119,_120,_121,_122,'false',_123,_124,_125,_126,_127,_128,_129,_130,_131}> + when let <_19> = + call %% Line 394 + 'erlang':%% Line 394 + '>=' + (%% Line 394 + X, %% Line 394 + 192) + in let <_20> = + call %% Line 394 + 'erlang':%% Line 394 + '=<' + (%% Line 394 + X, %% Line 394 + 223) + in %% Line 394 + call 'erlang':'and' + (_19, _20) -> + %% Line 395 + apply 'strip_continuations'/6 + (Rest, Handler, Acc, Stack, Config, 1) + %% Line 397 + <#{#(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config',_132,_133,_134,_135,_136,_137,'false',_138,_139,_140,_141,_142,_143,_144,_145,_146}> + when let <_21> = + call %% Line 398 + 'erlang':%% Line 398 + '>=' + (%% Line 398 + X, %% Line 398 + 224) + in let <_22> = + call %% Line 398 + 'erlang':%% Line 398 + '=<' + (%% Line 398 + X, %% Line 398 + 239) + in %% Line 398 + call 'erlang':'and' + (_21, _22) -> + %% Line 399 + apply 'strip_continuations'/6 + (Rest, Handler, Acc, Stack, Config, 2) + %% Line 401 + <#{#(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config',_147,_148,_149,_150,_151,_152,'false',_153,_154,_155,_156,_157,_158,_159,_160,_161}> + when let <_23> = + call %% Line 402 + 'erlang':%% Line 402 + '>=' + (%% Line 402 + X, %% Line 402 + 240) + in let <_24> = + call %% Line 402 + 'erlang':%% Line 402 + '=<' + (%% Line 402 + X, %% Line 402 + 247) + in %% Line 402 + call 'erlang':'and' + (_23, _24) -> + %% Line 403 + apply 'strip_continuations'/6 + (Rest, Handler, Acc, Stack, Config, 3) + %% Line 405 + <#{#<_162>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config',_163,_164,_165,_166,_167,_168,'false',_169,_170,_171,_172,_173,_174,_175,_176,_177}> when 'true' -> + %% Line 406 + apply 'string'/5 + (Rest, Handler, [Acc|[#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<189>(8,1,'integer',['unsigned'|['big']])}#]], Stack, Config) + %% Line 407 + when 'true' -> + ( case Config of + ( <( {'config',_178,_179,_180,_181,_182,_183,_184,_185,_186,_187,_188,_189,_190,_191,_rec12,_192} + -| ['compiler_generated'] )> when 'true' -> + case _rec12 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_27> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','string',Handler,Acc,Stack}, _27) + end + -| ['compiler_generated'] ) + ( <_193> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'count'/5 = + %% Line 410 + fun (_0,_1,_2,_3,_4) -> + let = + apply %% Line 411 + 'count'/3 + (_0, %% Line 411 + 0, _4) + in %% Line 412 + case _0 of + <#{#(Size,8,'binary',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#> when 'true' -> + %% Line 413 + apply 'string'/5 + (Rest, _1, [_2|[Clean|[]]], _3, _4) + ( <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + -| ['compiler_generated'] ) + end +'count'/3 = + %% Line 418 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <#{#<32>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_3> = + call %% Line 419 + 'erlang':%% Line 419 + '+' + (%% Line 419 + N, %% Line 419 + 1) + in %% Line 419 + apply 'count'/3 + (Rest, _3, Config) + %% Line 420 + <#{#<33>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_4> = + call %% Line 421 + 'erlang':%% Line 421 + '+' + (%% Line 421 + N, %% Line 421 + 1) + in %% Line 421 + apply 'count'/3 + (Rest, _4, Config) + %% Line 422 + <#{#<34>(8,1,'integer',['unsigned'|['big']]), + #<_104>('all',8,'binary',['unsigned'|['big']])}#,N,_105> when 'true' -> + N + %% Line 423 + <#{#<35>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_5> = + call %% Line 424 + 'erlang':%% Line 424 + '+' + (%% Line 424 + N, %% Line 424 + 1) + in %% Line 424 + apply 'count'/3 + (Rest, _5, Config) + %% Line 425 + <#{#<36>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_6> = + call %% Line 426 + 'erlang':%% Line 426 + '+' + (%% Line 426 + N, %% Line 426 + 1) + in %% Line 426 + apply 'count'/3 + (Rest, _6, Config) + %% Line 427 + <#{#<37>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_7> = + call %% Line 428 + 'erlang':%% Line 428 + '+' + (%% Line 428 + N, %% Line 428 + 1) + in %% Line 428 + apply 'count'/3 + (Rest, _7, Config) + %% Line 429 + <#{#<38>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_8> = + call %% Line 430 + 'erlang':%% Line 430 + '+' + (%% Line 430 + N, %% Line 430 + 1) + in %% Line 430 + apply 'count'/3 + (Rest, _8, Config) + %% Line 431 + <#{#<39>(8,1,'integer',['unsigned'|['big']]), + #<_106>('all',8,'binary',['unsigned'|['big']])}#,N,_107> when 'true' -> + N + %% Line 432 + <#{#<40>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_9> = + call %% Line 433 + 'erlang':%% Line 433 + '+' + (%% Line 433 + N, %% Line 433 + 1) + in %% Line 433 + apply 'count'/3 + (Rest, _9, Config) + %% Line 434 + <#{#<41>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_10> = + call %% Line 435 + 'erlang':%% Line 435 + '+' + (%% Line 435 + N, %% Line 435 + 1) + in %% Line 435 + apply 'count'/3 + (Rest, _10, Config) + %% Line 436 + <#{#<42>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_11> = + call %% Line 437 + 'erlang':%% Line 437 + '+' + (%% Line 437 + N, %% Line 437 + 1) + in %% Line 437 + apply 'count'/3 + (Rest, _11, Config) + %% Line 438 + <#{#<43>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_12> = + call %% Line 439 + 'erlang':%% Line 439 + '+' + (%% Line 439 + N, %% Line 439 + 1) + in %% Line 439 + apply 'count'/3 + (Rest, _12, Config) + %% Line 440 + <#{#<44>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_13> = + call %% Line 441 + 'erlang':%% Line 441 + '+' + (%% Line 441 + N, %% Line 441 + 1) + in %% Line 441 + apply 'count'/3 + (Rest, _13, Config) + %% Line 442 + <#{#<45>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_14> = + call %% Line 443 + 'erlang':%% Line 443 + '+' + (%% Line 443 + N, %% Line 443 + 1) + in %% Line 443 + apply 'count'/3 + (Rest, _14, Config) + %% Line 444 + <#{#<46>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_15> = + call %% Line 445 + 'erlang':%% Line 445 + '+' + (%% Line 445 + N, %% Line 445 + 1) + in %% Line 445 + apply 'count'/3 + (Rest, _15, Config) + %% Line 446 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<_108>('all',8,'binary',['unsigned'|['big']])}#,N,_109> when 'true' -> + N + %% Line 447 + <#{#<48>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_16> = + call %% Line 448 + 'erlang':%% Line 448 + '+' + (%% Line 448 + N, %% Line 448 + 1) + in %% Line 448 + apply 'count'/3 + (Rest, _16, Config) + %% Line 449 + <#{#<49>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_17> = + call %% Line 450 + 'erlang':%% Line 450 + '+' + (%% Line 450 + N, %% Line 450 + 1) + in %% Line 450 + apply 'count'/3 + (Rest, _17, Config) + %% Line 451 + <#{#<50>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_18> = + call %% Line 452 + 'erlang':%% Line 452 + '+' + (%% Line 452 + N, %% Line 452 + 1) + in %% Line 452 + apply 'count'/3 + (Rest, _18, Config) + %% Line 453 + <#{#<51>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_19> = + call %% Line 454 + 'erlang':%% Line 454 + '+' + (%% Line 454 + N, %% Line 454 + 1) + in %% Line 454 + apply 'count'/3 + (Rest, _19, Config) + %% Line 455 + <#{#<52>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_20> = + call %% Line 456 + 'erlang':%% Line 456 + '+' + (%% Line 456 + N, %% Line 456 + 1) + in %% Line 456 + apply 'count'/3 + (Rest, _20, Config) + %% Line 457 + <#{#<53>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_21> = + call %% Line 458 + 'erlang':%% Line 458 + '+' + (%% Line 458 + N, %% Line 458 + 1) + in %% Line 458 + apply 'count'/3 + (Rest, _21, Config) + %% Line 459 + <#{#<54>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_22> = + call %% Line 460 + 'erlang':%% Line 460 + '+' + (%% Line 460 + N, %% Line 460 + 1) + in %% Line 460 + apply 'count'/3 + (Rest, _22, Config) + %% Line 461 + <#{#<55>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_23> = + call %% Line 462 + 'erlang':%% Line 462 + '+' + (%% Line 462 + N, %% Line 462 + 1) + in %% Line 462 + apply 'count'/3 + (Rest, _23, Config) + %% Line 463 + <#{#<56>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_24> = + call %% Line 464 + 'erlang':%% Line 464 + '+' + (%% Line 464 + N, %% Line 464 + 1) + in %% Line 464 + apply 'count'/3 + (Rest, _24, Config) + %% Line 465 + <#{#<57>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_25> = + call %% Line 466 + 'erlang':%% Line 466 + '+' + (%% Line 466 + N, %% Line 466 + 1) + in %% Line 466 + apply 'count'/3 + (Rest, _25, Config) + %% Line 467 + <#{#<58>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_26> = + call %% Line 468 + 'erlang':%% Line 468 + '+' + (%% Line 468 + N, %% Line 468 + 1) + in %% Line 468 + apply 'count'/3 + (Rest, _26, Config) + %% Line 469 + <#{#<59>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_27> = + call %% Line 470 + 'erlang':%% Line 470 + '+' + (%% Line 470 + N, %% Line 470 + 1) + in %% Line 470 + apply 'count'/3 + (Rest, _27, Config) + %% Line 471 + <#{#<60>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_28> = + call %% Line 472 + 'erlang':%% Line 472 + '+' + (%% Line 472 + N, %% Line 472 + 1) + in %% Line 472 + apply 'count'/3 + (Rest, _28, Config) + %% Line 473 + <#{#<61>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_29> = + call %% Line 474 + 'erlang':%% Line 474 + '+' + (%% Line 474 + N, %% Line 474 + 1) + in %% Line 474 + apply 'count'/3 + (Rest, _29, Config) + %% Line 475 + <#{#<62>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_30> = + call %% Line 476 + 'erlang':%% Line 476 + '+' + (%% Line 476 + N, %% Line 476 + 1) + in %% Line 476 + apply 'count'/3 + (Rest, _30, Config) + %% Line 477 + <#{#<63>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_31> = + call %% Line 478 + 'erlang':%% Line 478 + '+' + (%% Line 478 + N, %% Line 478 + 1) + in %% Line 478 + apply 'count'/3 + (Rest, _31, Config) + %% Line 479 + <#{#<64>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_32> = + call %% Line 480 + 'erlang':%% Line 480 + '+' + (%% Line 480 + N, %% Line 480 + 1) + in %% Line 480 + apply 'count'/3 + (Rest, _32, Config) + %% Line 481 + <#{#<65>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_33> = + call %% Line 482 + 'erlang':%% Line 482 + '+' + (%% Line 482 + N, %% Line 482 + 1) + in %% Line 482 + apply 'count'/3 + (Rest, _33, Config) + %% Line 483 + <#{#<66>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_34> = + call %% Line 484 + 'erlang':%% Line 484 + '+' + (%% Line 484 + N, %% Line 484 + 1) + in %% Line 484 + apply 'count'/3 + (Rest, _34, Config) + %% Line 485 + <#{#<67>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_35> = + call %% Line 486 + 'erlang':%% Line 486 + '+' + (%% Line 486 + N, %% Line 486 + 1) + in %% Line 486 + apply 'count'/3 + (Rest, _35, Config) + %% Line 487 + <#{#<68>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_36> = + call %% Line 488 + 'erlang':%% Line 488 + '+' + (%% Line 488 + N, %% Line 488 + 1) + in %% Line 488 + apply 'count'/3 + (Rest, _36, Config) + %% Line 489 + <#{#<69>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_37> = + call %% Line 490 + 'erlang':%% Line 490 + '+' + (%% Line 490 + N, %% Line 490 + 1) + in %% Line 490 + apply 'count'/3 + (Rest, _37, Config) + %% Line 491 + <#{#<70>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_38> = + call %% Line 492 + 'erlang':%% Line 492 + '+' + (%% Line 492 + N, %% Line 492 + 1) + in %% Line 492 + apply 'count'/3 + (Rest, _38, Config) + %% Line 493 + <#{#<71>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_39> = + call %% Line 494 + 'erlang':%% Line 494 + '+' + (%% Line 494 + N, %% Line 494 + 1) + in %% Line 494 + apply 'count'/3 + (Rest, _39, Config) + %% Line 495 + <#{#<72>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_40> = + call %% Line 496 + 'erlang':%% Line 496 + '+' + (%% Line 496 + N, %% Line 496 + 1) + in %% Line 496 + apply 'count'/3 + (Rest, _40, Config) + %% Line 497 + <#{#<73>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_41> = + call %% Line 498 + 'erlang':%% Line 498 + '+' + (%% Line 498 + N, %% Line 498 + 1) + in %% Line 498 + apply 'count'/3 + (Rest, _41, Config) + %% Line 499 + <#{#<74>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_42> = + call %% Line 500 + 'erlang':%% Line 500 + '+' + (%% Line 500 + N, %% Line 500 + 1) + in %% Line 500 + apply 'count'/3 + (Rest, _42, Config) + %% Line 501 + <#{#<75>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_43> = + call %% Line 502 + 'erlang':%% Line 502 + '+' + (%% Line 502 + N, %% Line 502 + 1) + in %% Line 502 + apply 'count'/3 + (Rest, _43, Config) + %% Line 503 + <#{#<76>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_44> = + call %% Line 504 + 'erlang':%% Line 504 + '+' + (%% Line 504 + N, %% Line 504 + 1) + in %% Line 504 + apply 'count'/3 + (Rest, _44, Config) + %% Line 505 + <#{#<77>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_45> = + call %% Line 506 + 'erlang':%% Line 506 + '+' + (%% Line 506 + N, %% Line 506 + 1) + in %% Line 506 + apply 'count'/3 + (Rest, _45, Config) + %% Line 507 + <#{#<78>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_46> = + call %% Line 508 + 'erlang':%% Line 508 + '+' + (%% Line 508 + N, %% Line 508 + 1) + in %% Line 508 + apply 'count'/3 + (Rest, _46, Config) + %% Line 509 + <#{#<79>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_47> = + call %% Line 510 + 'erlang':%% Line 510 + '+' + (%% Line 510 + N, %% Line 510 + 1) + in %% Line 510 + apply 'count'/3 + (Rest, _47, Config) + %% Line 511 + <#{#<80>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_48> = + call %% Line 512 + 'erlang':%% Line 512 + '+' + (%% Line 512 + N, %% Line 512 + 1) + in %% Line 512 + apply 'count'/3 + (Rest, _48, Config) + %% Line 513 + <#{#<81>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_49> = + call %% Line 514 + 'erlang':%% Line 514 + '+' + (%% Line 514 + N, %% Line 514 + 1) + in %% Line 514 + apply 'count'/3 + (Rest, _49, Config) + %% Line 515 + <#{#<82>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_50> = + call %% Line 516 + 'erlang':%% Line 516 + '+' + (%% Line 516 + N, %% Line 516 + 1) + in %% Line 516 + apply 'count'/3 + (Rest, _50, Config) + %% Line 517 + <#{#<83>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_51> = + call %% Line 518 + 'erlang':%% Line 518 + '+' + (%% Line 518 + N, %% Line 518 + 1) + in %% Line 518 + apply 'count'/3 + (Rest, _51, Config) + %% Line 519 + <#{#<84>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_52> = + call %% Line 520 + 'erlang':%% Line 520 + '+' + (%% Line 520 + N, %% Line 520 + 1) + in %% Line 520 + apply 'count'/3 + (Rest, _52, Config) + %% Line 521 + <#{#<85>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_53> = + call %% Line 522 + 'erlang':%% Line 522 + '+' + (%% Line 522 + N, %% Line 522 + 1) + in %% Line 522 + apply 'count'/3 + (Rest, _53, Config) + %% Line 523 + <#{#<86>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_54> = + call %% Line 524 + 'erlang':%% Line 524 + '+' + (%% Line 524 + N, %% Line 524 + 1) + in %% Line 524 + apply 'count'/3 + (Rest, _54, Config) + %% Line 525 + <#{#<87>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_55> = + call %% Line 526 + 'erlang':%% Line 526 + '+' + (%% Line 526 + N, %% Line 526 + 1) + in %% Line 526 + apply 'count'/3 + (Rest, _55, Config) + %% Line 527 + <#{#<88>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_56> = + call %% Line 528 + 'erlang':%% Line 528 + '+' + (%% Line 528 + N, %% Line 528 + 1) + in %% Line 528 + apply 'count'/3 + (Rest, _56, Config) + %% Line 529 + <#{#<89>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_57> = + call %% Line 530 + 'erlang':%% Line 530 + '+' + (%% Line 530 + N, %% Line 530 + 1) + in %% Line 530 + apply 'count'/3 + (Rest, _57, Config) + %% Line 531 + <#{#<90>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_58> = + call %% Line 532 + 'erlang':%% Line 532 + '+' + (%% Line 532 + N, %% Line 532 + 1) + in %% Line 532 + apply 'count'/3 + (Rest, _58, Config) + %% Line 533 + <#{#<91>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_59> = + call %% Line 534 + 'erlang':%% Line 534 + '+' + (%% Line 534 + N, %% Line 534 + 1) + in %% Line 534 + apply 'count'/3 + (Rest, _59, Config) + %% Line 535 + <#{#<92>(8,1,'integer',['unsigned'|['big']]), + #<_110>('all',8,'binary',['unsigned'|['big']])}#,N,_111> when 'true' -> + N + %% Line 536 + <#{#<93>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_60> = + call %% Line 537 + 'erlang':%% Line 537 + '+' + (%% Line 537 + N, %% Line 537 + 1) + in %% Line 537 + apply 'count'/3 + (Rest, _60, Config) + %% Line 538 + <#{#<94>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_61> = + call %% Line 539 + 'erlang':%% Line 539 + '+' + (%% Line 539 + N, %% Line 539 + 1) + in %% Line 539 + apply 'count'/3 + (Rest, _61, Config) + %% Line 540 + <#{#<95>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_62> = + call %% Line 541 + 'erlang':%% Line 541 + '+' + (%% Line 541 + N, %% Line 541 + 1) + in %% Line 541 + apply 'count'/3 + (Rest, _62, Config) + %% Line 542 + <#{#<96>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_63> = + call %% Line 543 + 'erlang':%% Line 543 + '+' + (%% Line 543 + N, %% Line 543 + 1) + in %% Line 543 + apply 'count'/3 + (Rest, _63, Config) + %% Line 544 + <#{#<97>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_64> = + call %% Line 545 + 'erlang':%% Line 545 + '+' + (%% Line 545 + N, %% Line 545 + 1) + in %% Line 545 + apply 'count'/3 + (Rest, _64, Config) + %% Line 546 + <#{#<98>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_65> = + call %% Line 547 + 'erlang':%% Line 547 + '+' + (%% Line 547 + N, %% Line 547 + 1) + in %% Line 547 + apply 'count'/3 + (Rest, _65, Config) + %% Line 548 + <#{#<99>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_66> = + call %% Line 549 + 'erlang':%% Line 549 + '+' + (%% Line 549 + N, %% Line 549 + 1) + in %% Line 549 + apply 'count'/3 + (Rest, _66, Config) + %% Line 550 + <#{#<100>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_67> = + call %% Line 551 + 'erlang':%% Line 551 + '+' + (%% Line 551 + N, %% Line 551 + 1) + in %% Line 551 + apply 'count'/3 + (Rest, _67, Config) + %% Line 552 + <#{#<101>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_68> = + call %% Line 553 + 'erlang':%% Line 553 + '+' + (%% Line 553 + N, %% Line 553 + 1) + in %% Line 553 + apply 'count'/3 + (Rest, _68, Config) + %% Line 554 + <#{#<102>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_69> = + call %% Line 555 + 'erlang':%% Line 555 + '+' + (%% Line 555 + N, %% Line 555 + 1) + in %% Line 555 + apply 'count'/3 + (Rest, _69, Config) + %% Line 556 + <#{#<103>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_70> = + call %% Line 557 + 'erlang':%% Line 557 + '+' + (%% Line 557 + N, %% Line 557 + 1) + in %% Line 557 + apply 'count'/3 + (Rest, _70, Config) + %% Line 558 + <#{#<104>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_71> = + call %% Line 559 + 'erlang':%% Line 559 + '+' + (%% Line 559 + N, %% Line 559 + 1) + in %% Line 559 + apply 'count'/3 + (Rest, _71, Config) + %% Line 560 + <#{#<105>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_72> = + call %% Line 561 + 'erlang':%% Line 561 + '+' + (%% Line 561 + N, %% Line 561 + 1) + in %% Line 561 + apply 'count'/3 + (Rest, _72, Config) + %% Line 562 + <#{#<106>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_73> = + call %% Line 563 + 'erlang':%% Line 563 + '+' + (%% Line 563 + N, %% Line 563 + 1) + in %% Line 563 + apply 'count'/3 + (Rest, _73, Config) + %% Line 564 + <#{#<107>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_74> = + call %% Line 565 + 'erlang':%% Line 565 + '+' + (%% Line 565 + N, %% Line 565 + 1) + in %% Line 565 + apply 'count'/3 + (Rest, _74, Config) + %% Line 566 + <#{#<108>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_75> = + call %% Line 567 + 'erlang':%% Line 567 + '+' + (%% Line 567 + N, %% Line 567 + 1) + in %% Line 567 + apply 'count'/3 + (Rest, _75, Config) + %% Line 568 + <#{#<109>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_76> = + call %% Line 569 + 'erlang':%% Line 569 + '+' + (%% Line 569 + N, %% Line 569 + 1) + in %% Line 569 + apply 'count'/3 + (Rest, _76, Config) + %% Line 570 + <#{#<110>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_77> = + call %% Line 571 + 'erlang':%% Line 571 + '+' + (%% Line 571 + N, %% Line 571 + 1) + in %% Line 571 + apply 'count'/3 + (Rest, _77, Config) + %% Line 572 + <#{#<111>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_78> = + call %% Line 573 + 'erlang':%% Line 573 + '+' + (%% Line 573 + N, %% Line 573 + 1) + in %% Line 573 + apply 'count'/3 + (Rest, _78, Config) + %% Line 574 + <#{#<112>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_79> = + call %% Line 575 + 'erlang':%% Line 575 + '+' + (%% Line 575 + N, %% Line 575 + 1) + in %% Line 575 + apply 'count'/3 + (Rest, _79, Config) + %% Line 576 + <#{#<113>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_80> = + call %% Line 577 + 'erlang':%% Line 577 + '+' + (%% Line 577 + N, %% Line 577 + 1) + in %% Line 577 + apply 'count'/3 + (Rest, _80, Config) + %% Line 578 + <#{#<114>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_81> = + call %% Line 579 + 'erlang':%% Line 579 + '+' + (%% Line 579 + N, %% Line 579 + 1) + in %% Line 579 + apply 'count'/3 + (Rest, _81, Config) + %% Line 580 + <#{#<115>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_82> = + call %% Line 581 + 'erlang':%% Line 581 + '+' + (%% Line 581 + N, %% Line 581 + 1) + in %% Line 581 + apply 'count'/3 + (Rest, _82, Config) + %% Line 582 + <#{#<116>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_83> = + call %% Line 583 + 'erlang':%% Line 583 + '+' + (%% Line 583 + N, %% Line 583 + 1) + in %% Line 583 + apply 'count'/3 + (Rest, _83, Config) + %% Line 584 + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_84> = + call %% Line 585 + 'erlang':%% Line 585 + '+' + (%% Line 585 + N, %% Line 585 + 1) + in %% Line 585 + apply 'count'/3 + (Rest, _84, Config) + %% Line 586 + <#{#<118>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_85> = + call %% Line 587 + 'erlang':%% Line 587 + '+' + (%% Line 587 + N, %% Line 587 + 1) + in %% Line 587 + apply 'count'/3 + (Rest, _85, Config) + %% Line 588 + <#{#<119>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_86> = + call %% Line 589 + 'erlang':%% Line 589 + '+' + (%% Line 589 + N, %% Line 589 + 1) + in %% Line 589 + apply 'count'/3 + (Rest, _86, Config) + %% Line 590 + <#{#<120>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_87> = + call %% Line 591 + 'erlang':%% Line 591 + '+' + (%% Line 591 + N, %% Line 591 + 1) + in %% Line 591 + apply 'count'/3 + (Rest, _87, Config) + %% Line 592 + <#{#<121>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_88> = + call %% Line 593 + 'erlang':%% Line 593 + '+' + (%% Line 593 + N, %% Line 593 + 1) + in %% Line 593 + apply 'count'/3 + (Rest, _88, Config) + %% Line 594 + <#{#<122>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_89> = + call %% Line 595 + 'erlang':%% Line 595 + '+' + (%% Line 595 + N, %% Line 595 + 1) + in %% Line 595 + apply 'count'/3 + (Rest, _89, Config) + %% Line 596 + <#{#<123>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_90> = + call %% Line 597 + 'erlang':%% Line 597 + '+' + (%% Line 597 + N, %% Line 597 + 1) + in %% Line 597 + apply 'count'/3 + (Rest, _90, Config) + %% Line 598 + <#{#<124>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_91> = + call %% Line 599 + 'erlang':%% Line 599 + '+' + (%% Line 599 + N, %% Line 599 + 1) + in %% Line 599 + apply 'count'/3 + (Rest, _91, Config) + %% Line 600 + <#{#<125>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_92> = + call %% Line 601 + 'erlang':%% Line 601 + '+' + (%% Line 601 + N, %% Line 601 + 1) + in %% Line 601 + apply 'count'/3 + (Rest, _92, Config) + %% Line 602 + <#{#<126>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_93> = + call %% Line 603 + 'erlang':%% Line 603 + '+' + (%% Line 603 + N, %% Line 603 + 1) + in %% Line 603 + apply 'count'/3 + (Rest, _93, Config) + %% Line 604 + <#{#<127>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_94> = + call %% Line 605 + 'erlang':%% Line 605 + '+' + (%% Line 605 + N, %% Line 605 + 1) + in %% Line 605 + apply 'count'/3 + (Rest, _94, Config) + %% Line 606 + <#{#<_112>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config = {'config','true',_113,_114,_115,_116,_117,_118,_119,_120,_121,_122,_123,_124,_125,_126,_127}> when 'true' -> + let <_95> = + call %% Line 607 + 'erlang':%% Line 607 + '+' + (%% Line 607 + N, %% Line 607 + 1) + in %% Line 607 + apply 'count'/3 + (Rest, _95, Config) + %% Line 608 + <#{#<_128>('undefined','undefined','utf8',['unsigned'|['big']]), + #<_129>('all',8,'binary',['unsigned'|['big']])}#,N,{'config',_130,_131,_132,_133,_134,_135,_136,_137,_138,_139,_140,_141,'true',_142,_143,_144}> when 'true' -> + N + %% Line 609 + <#{#('undefined','undefined','utf8',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config = {'config',_145,_146,_147,_148,_149,_150,_151,_152,_153,'false',_154,_155,_156,_157,_158,_159}> + when call 'erlang':'<' + (X, + 32) -> + let <_96> = + call %% Line 610 + 'erlang':%% Line 610 + '+' + (%% Line 610 + N, %% Line 610 + 1) + in %% Line 610 + apply 'count'/3 + (Rest, _96, Config) + %% Line 611 + <#{#('undefined','undefined','utf8',['unsigned'|['big']]), + #<_160>('all',8,'binary',['unsigned'|['big']])}#,N,{'config',_161,_162,_163,_164,_165,_166,_167,_168,_169,'true',_170,_171,_172,_173,_174,_175}> + when call 'erlang':'<' + (X, + 32) -> + N + %% Line 612 + <#{#('undefined','undefined','utf8',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + %% Line 613 + case X of + %% Line 614 + <_176> + when call 'erlang':'<' + (X, + 2048) -> + let <_97> = + call 'erlang':'+' + (N, 2) + in apply 'count'/3 + (Rest, _97, Config) + %% Line 616 + <8232> when 'true' -> + N + %% Line 617 + <8233> when 'true' -> + N + %% Line 618 + <_179> + when call 'erlang':'<' + (X, + 65536) -> + let <_98> = + call 'erlang':'+' + (N, 3) + in apply 'count'/3 + (Rest, _98, Config) + %% Line 619 + <_182> when 'true' -> + let <_99> = + call 'erlang':'+' + (N, 4) + in apply 'count'/3 + (Rest, _99, Config) + end + %% Line 621 + <_183,N,_184> when 'true' -> + N + end +'doublequote'/5 = + %% Line 624 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + when 'true' -> + let <_5> = + call %% Line 625 + 'erlang':%% Line 625 + 'iolist_to_binary' + (%% Line 625 + Acc) + in let <_209> = {%% Line 625 + ( 'key' + -| ['compiler_generated'] ),_5} + in ( case <_209,%% Line 625 + Handler,%% Line 625 + Config> of + ( when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_213> = + call _212:( 'handle_event' + -| ['compiler_generated'] ) + (Event, State) + in let <_6> = {_212,_213} + in %% Line 625 + apply 'colon'/4 + (Rest, _6, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_6,_214,_215> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),_6,_214,_215} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 626 + when 'true' -> + let <_7> = + case %% Line 627 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_218,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<34>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 752 + ( <( {( 'config' + -| ['compiler_generated'] ),_102,_103,( 'true' + -| ['compiler_generated'] ),_104,_105,_106,_107,_108,_109,_110,_111,_112,_113,_114,_115,_116} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<34>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<34>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 627 + apply 'string'/5 + (Rest, Handler, [Acc|[_7|[]]], Stack, Config) + %% Line 628 + <#{}#,Handler,Acc,Stack = ['singlequote'|_17],Config> when 'true' -> + %% Line 629 + apply 'incomplete'/6 + ('string', #{#<34>(8,1,'integer',['unsigned'|['big']])}#, Handler, Acc, Stack, Config) + %% Line 630 + when 'true' -> + let <_8> = + call %% Line 631 + 'erlang':%% Line 631 + 'iolist_to_binary' + (%% Line 631 + Acc) + in let <_224> = {%% Line 631 + ( 'string' + -| ['compiler_generated'] ),_8} + in ( case <_224,%% Line 631 + Handler,%% Line 631 + Config> of + ( when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_228> = + call _227:( 'handle_event' + -| ['compiler_generated'] ) + (Event, State) + in let <_9> = {_227,_228} + in %% Line 631 + apply 'maybe_done'/4 + (Rest, _9, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_6,_5,_229> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),_6,_5,_229} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'singlequote'/5 = + %% Line 634 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + when 'true' -> + let <_5> = + call %% Line 635 + 'erlang':%% Line 635 + 'iolist_to_binary' + (%% Line 635 + Acc) + in let <_14> = {%% Line 635 + ( 'key' + -| ['compiler_generated'] ),_5} + in ( case <_14,%% Line 635 + Handler,%% Line 635 + Config> of + ( when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_18> = + call _17:( 'handle_event' + -| ['compiler_generated'] ) + (Event, State) + in let <_6> = {_17,_18} + in %% Line 635 + apply 'colon'/4 + (Rest, _6, _@r0, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_6,_19,_20> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),_6,_19,_20} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 636 + when 'true' -> + let <_7> = + call %% Line 637 + 'erlang':%% Line 637 + 'iolist_to_binary' + (%% Line 637 + Acc) + in let <_21> = {%% Line 637 + ( 'string' + -| ['compiler_generated'] ),_7} + in ( case <_21,%% Line 637 + Handler,%% Line 637 + Config> of + ( when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_25> = + call _24:( 'handle_event' + -| ['compiler_generated'] ) + (Event, State) + in let <_8> = {_24,_25} + in %% Line 637 + apply 'maybe_done'/4 + (Rest, _8, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_6,_5,_26> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),_6,_5,_26} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 638 + when 'true' -> + %% Line 639 + apply 'string'/5 + (Rest, Handler, [Acc|[39]], Stack, Config) + end +'strip_continuations'/6 = + %% Line 644 + fun (_0,_1,_2,_3,_4,_5) -> + case <_0,_1,_2,_3,_4,_5> of + <#{#('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config,0> when 'true' -> + %% Line 645 + apply 'string'/5 + (Rest, Handler, [Acc|[#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<189>(8,1,'integer',['unsigned'|['big']])}#]], Stack, Config) + %% Line 646 + <#{#(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config,N> + when let <_6> = + call 'erlang':'>=' + (X, 128) + in let <_7> = + call 'erlang':'=<' + (X, 191) + in call 'erlang':'and' + (_6, _7) -> + let <_8> = + call %% Line 647 + 'erlang':%% Line 647 + '-' + (%% Line 647 + N, %% Line 647 + 1) + in %% Line 647 + apply 'strip_continuations'/6 + (Rest, Handler, Acc, Stack, Config, _8) + %% Line 651 + <#{}#,Handler,Acc,Stack,Config,N> when 'true' -> + %% Line 652 + case N of + %% Line 653 + <1> when 'true' -> + apply 'incomplete'/6 + ('string', #{#<192>(8,1,'integer',['unsigned'|['big']])}#, Handler, Acc, Stack, Config) + %% Line 654 + <2> when 'true' -> + apply 'incomplete'/6 + ('string', #{#<224>(8,1,'integer',['unsigned'|['big']])}#, Handler, Acc, Stack, Config) + %% Line 655 + <3> when 'true' -> + apply 'incomplete'/6 + ('string', #{#<240>(8,1,'integer',['unsigned'|['big']])}#, Handler, Acc, Stack, Config) + ( <_9> when 'true' -> + primop 'match_fail' + ({'case_clause',_9}) + -| ['compiler_generated'] ) + end + %% Line 659 + <#{#('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config,_16> when 'true' -> + %% Line 660 + apply 'string'/5 + (Rest, Handler, [Acc|[#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<189>(8,1,'integer',['unsigned'|['big']])}#]], Stack, Config) + ( <_15,_14,_13,_12,_11,_10> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_15,_14,_13,_12,_11,_10}) + -| [{'function_name',{'strip_continuations',6}}] ) + -| ['compiler_generated'] ) + end +'unescape'/5 = + %% Line 665 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + <#{#<92>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config','true',_417,_418,_419,_420,_421,_422,_423,_424,_425,_426,_427,_428,_429,_430,_431}> when 'true' -> + let <_5> = + #{#<%% Line 666 + 92>(%% Line 666 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 666 + Rest>(%% Line 666 + 'all',8,'binary',['unsigned'|['big']])}# + in %% Line 666 + apply 'string'/5 + (_5, Handler, [Acc|[#{#<92>(8,1,'integer',['unsigned'|['big']])}#]], Stack, Config) + %% Line 667 + <#{#(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config','true',_432,_433,_434,_435,_436,_437,_438,_439,_440,_441,_442,_443,_444,_445,_446}> when 'true' -> + let <_6> = + #{#<%% Line 668 + 92>(%% Line 668 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 668 + C>(%% Line 668 + 8,1,'integer',['unsigned'|['big']])}# + in %% Line 668 + apply 'string'/5 + (Rest, Handler, [Acc|[_6|[]]], Stack, Config) + %% Line 669 + <#{#<98>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_7> = + case %% Line 670 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<8>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 747 + ( <( {( 'config' + -| ['compiler_generated'] ),_27,_28,( 'true' + -| ['compiler_generated'] ),_29,_30,_31,_32,_33,_34,_35,_36,_37,_38,_39,_40,_41} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<98>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 764 + ( <( {( 'config' + -| ['compiler_generated'] ),_194,_195,( 'true' + -| ['compiler_generated'] ),_196,_197,_198,_199,_200,_201,_202,_203,_204,_205,_206,_207,_208} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 765 + ( apply 'json_escape_sequence'/1 + (( 8 + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<8>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 670 + apply 'string'/5 + (Rest, Handler, [Acc|[_7|[]]], Stack, Config) + %% Line 671 + <#{#<102>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_8> = + case %% Line 672 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<12>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 750 + ( <( {( 'config' + -| ['compiler_generated'] ),_72,_73,( 'true' + -| ['compiler_generated'] ),_74,_75,_76,_77,_78,_79,_80,_81,_82,_83,_84,_85,_86} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<102>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 764 + ( <( {( 'config' + -| ['compiler_generated'] ),_194,_195,( 'true' + -| ['compiler_generated'] ),_196,_197,_198,_199,_200,_201,_202,_203,_204,_205,_206,_207,_208} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 765 + ( apply 'json_escape_sequence'/1 + (( 12 + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<12>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 672 + apply 'string'/5 + (Rest, Handler, [Acc|[_8|[]]], Stack, Config) + %% Line 673 + <#{#<110>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_9> = + case %% Line 674 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<10>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 749 + ( <( {( 'config' + -| ['compiler_generated'] ),_57,_58,( 'true' + -| ['compiler_generated'] ),_59,_60,_61,_62,_63,_64,_65,_66,_67,_68,_69,_70,_71} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<110>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 764 + ( <( {( 'config' + -| ['compiler_generated'] ),_194,_195,( 'true' + -| ['compiler_generated'] ),_196,_197,_198,_199,_200,_201,_202,_203,_204,_205,_206,_207,_208} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 765 + ( apply 'json_escape_sequence'/1 + (( 10 + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<10>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 674 + apply 'string'/5 + (Rest, Handler, [Acc|[_9|[]]], Stack, Config) + %% Line 675 + <#{#<114>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_10> = + case %% Line 676 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<13>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 751 + ( <( {( 'config' + -| ['compiler_generated'] ),_87,_88,( 'true' + -| ['compiler_generated'] ),_89,_90,_91,_92,_93,_94,_95,_96,_97,_98,_99,_100,_101} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<114>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 764 + ( <( {( 'config' + -| ['compiler_generated'] ),_194,_195,( 'true' + -| ['compiler_generated'] ),_196,_197,_198,_199,_200,_201,_202,_203,_204,_205,_206,_207,_208} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 765 + ( apply 'json_escape_sequence'/1 + (( 13 + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<13>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 676 + apply 'string'/5 + (Rest, Handler, [Acc|[_10|[]]], Stack, Config) + %% Line 677 + <#{#<116>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_11> = + case %% Line 678 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<9>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 748 + ( <( {( 'config' + -| ['compiler_generated'] ),_42,_43,( 'true' + -| ['compiler_generated'] ),_44,_45,_46,_47,_48,_49,_50,_51,_52,_53,_54,_55,_56} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<116>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 764 + ( <( {( 'config' + -| ['compiler_generated'] ),_194,_195,( 'true' + -| ['compiler_generated'] ),_196,_197,_198,_199,_200,_201,_202,_203,_204,_205,_206,_207,_208} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 765 + ( apply 'json_escape_sequence'/1 + (( 9 + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<9>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 678 + apply 'string'/5 + (Rest, Handler, [Acc|[_11|[]]], Stack, Config) + %% Line 679 + <#{#<34>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_12> = + case %% Line 680 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<34>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 752 + ( <( {( 'config' + -| ['compiler_generated'] ),_102,_103,( 'true' + -| ['compiler_generated'] ),_104,_105,_106,_107,_108,_109,_110,_111,_112,_113,_114,_115,_116} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<34>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<34>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 680 + apply 'string'/5 + (Rest, Handler, [Acc|[_12|[]]], Stack, Config) + %% Line 681 + <#{#<39>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config = {'config',_447,_448,_449,_450,_451,_452,_453,'false',_454,_455,_456,_457,_458,_459,_460,_461}> when 'true' -> + %% Line 682 + apply 'string'/5 + (Rest, Handler, [Acc|[#{#<39>(8,1,'integer',['unsigned'|['big']])}#]], Stack, Config) + %% Line 683 + <#{#<92>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_13> = + case %% Line 684 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 758 + ( <( {( 'config' + -| ['compiler_generated'] ),_148,_149,( 'true' + -| ['compiler_generated'] ),_150,_151,_152,_153,_154,_155,_156,_157,_158,_159,_160,_161,_162} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<92>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 684 + apply 'string'/5 + (Rest, Handler, [Acc|[_13|[]]], Stack, Config) + %% Line 685 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> when 'true' -> + let <_14> = + case %% Line 686 + Config of + %% Line 746 + ( <( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<47>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 753 + ( <( _595 = ( {( 'config' + -| ['compiler_generated'] ),_117,_118,( 'true' + -| ['compiler_generated'] ),_119,_120,_121,_122,_123,_124,_125,_126,_127,_128,_129,_130,_131} + -| ['compiler_generated'] ) + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 754 + ( case _595 of + ( <( {( 'config' + -| ['compiler_generated'] ),_132,_rec18,_133,_134,_135,_136,_137,_138,_139,_140,_141,_142,_143,_144,_145,_146} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( case _rec18 of + %% Line 755 + ( <( 'true' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 756 + ( <( 'false' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<47>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_597> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'case_clause' + -| ['compiler_generated'] ),_597} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_147> when ( 'true' + -| ['compiler_generated'] ) -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( <_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<47>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 686 + apply 'string'/5 + (Rest, Handler, [Acc|[_14|[]]], Stack, Config) + %% Line 687 + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #<92>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> + when %% Line 688 + try + ( let <_25> = + case call 'erlang':'==' + (A, 56) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 57) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 98) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'==' + (A, 66) + -| ['compiler_generated'] ) + ( <_19> when 'true' -> + _19 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_18> when 'true' -> + _18 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_17> when 'true' -> + _17 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_16> when 'true' -> + _16 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_15> when 'true' -> + _15 + -| ['compiler_generated'] ) + end + in let <_26> = + call 'erlang':'=:=' + (( _25 + -| ['compiler_generated'] ), 'true') + in ( let <_41> = + case %% Line 689 + call 'erlang':'==' + (X, 99) of + %% Line 689 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 689 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (X, 100) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (X, 101) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (X, 102) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (X, 67) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (X, 68) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (X, 69) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'==' + (X, 70) + -| ['compiler_generated'] ) + ( <_33> when 'true' -> + _33 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_32> when 'true' -> + _32 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_31> when 'true' -> + _31 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_30> when 'true' -> + _30 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_29> when 'true' -> + _29 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_28> when 'true' -> + _28 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 689 + ( <_27> when 'true' -> + _27 + -| ['compiler_generated'] ) + end + in let <_42> = + call 'erlang':'=:=' + (%% Line 689 + ( _41 + -| ['compiler_generated'] ), 'true') + in ( let <_45> = + case %% Line 690 + call 'erlang':'==' + (F, 100) of + %% Line 690 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 690 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'==' + (F, 68) + -| ['compiler_generated'] ) + %% Line 690 + ( <_43> when 'true' -> + _43 + -| ['compiler_generated'] ) + end + in let <_46> = + call 'erlang':'=:=' + (%% Line 690 + ( _45 + -| ['compiler_generated'] ), 'true') + in ( let <_49> = + case %% Line 691 + call 'erlang':'==' + (G, 100) of + %% Line 691 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 691 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'==' + (G, 68) + -| ['compiler_generated'] ) + %% Line 691 + ( <_47> when 'true' -> + _47 + -| ['compiler_generated'] ) + end + in let <_50> = + call 'erlang':'=:=' + (%% Line 691 + ( _49 + -| ['compiler_generated'] ), 'true') + in let <_54> = + case %% Line 692 + call 'erlang':'>=' + (B, 97) of + %% Line 692 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 102) + -| ['compiler_generated'] ) + %% Line 692 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 692 + ( <_52> when 'true' -> + _52 + -| ['compiler_generated'] ) + end + in ( let <_63> = + case _54 of + %% Line 692 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 692 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_58> = + case call 'erlang':'>=' + (B, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_56> when 'true' -> + _56 + -| ['compiler_generated'] ) + end + in ( case _58 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (B, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_59> when 'true' -> + _59 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_55> when 'true' -> + _55 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 692 + ( <_51> when 'true' -> + _51 + -| ['compiler_generated'] ) + end + in let <_64> = + call 'erlang':'=:=' + (%% Line 692 + ( _63 + -| ['compiler_generated'] ), 'true') + in let <_68> = + case %% Line 692 + call 'erlang':'>=' + (C, 97) of + %% Line 692 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 102) + -| ['compiler_generated'] ) + %% Line 692 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 692 + ( <_66> when 'true' -> + _66 + -| ['compiler_generated'] ) + end + in ( let <_77> = + case _68 of + %% Line 692 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 692 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_72> = + case call 'erlang':'>=' + (C, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_70> when 'true' -> + _70 + -| ['compiler_generated'] ) + end + in ( case _72 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (C, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_73> when 'true' -> + _73 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_69> when 'true' -> + _69 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 692 + ( <_65> when 'true' -> + _65 + -| ['compiler_generated'] ) + end + in let <_78> = + call 'erlang':'=:=' + (%% Line 692 + ( _77 + -| ['compiler_generated'] ), 'true') + in let <_82> = + case %% Line 692 + call 'erlang':'>=' + (Y, 97) of + %% Line 692 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Y, 102) + -| ['compiler_generated'] ) + %% Line 692 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 692 + ( <_80> when 'true' -> + _80 + -| ['compiler_generated'] ) + end + in ( let <_91> = + case _82 of + %% Line 692 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 692 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_86> = + case call 'erlang':'>=' + (Y, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Y, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_84> when 'true' -> + _84 + -| ['compiler_generated'] ) + end + in ( case _86 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (Y, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Y, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_87> when 'true' -> + _87 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_83> when 'true' -> + _83 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 692 + ( <_79> when 'true' -> + _79 + -| ['compiler_generated'] ) + end + in let <_92> = + call 'erlang':'=:=' + (%% Line 692 + ( _91 + -| ['compiler_generated'] ), 'true') + in let <_96> = + case %% Line 692 + call 'erlang':'>=' + (Z, 97) of + %% Line 692 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Z, 102) + -| ['compiler_generated'] ) + %% Line 692 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 692 + ( <_94> when 'true' -> + _94 + -| ['compiler_generated'] ) + end + in ( let <_105> = + case _96 of + %% Line 692 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 692 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_100> = + case call 'erlang':'>=' + (Z, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Z, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_98> when 'true' -> + _98 + -| ['compiler_generated'] ) + end + in ( case _100 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (Z, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Z, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_101> when 'true' -> + _101 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_97> when 'true' -> + _97 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 692 + ( <_93> when 'true' -> + _93 + -| ['compiler_generated'] ) + end + in let <_106> = + call 'erlang':'=:=' + (%% Line 692 + ( _105 + -| ['compiler_generated'] ), 'true') + in let <_107> = + call 'erlang':'and' + (_92, _106) + in let <_108> = + call 'erlang':'and' + (_78, _107) + in let <_109> = + call 'erlang':'and' + (_64, _108) + in let <_110> = + call 'erlang':'and' + (_50, _109) + in let <_111> = + call 'erlang':'and' + (_46, _110) + in let <_112> = + call 'erlang':'and' + (_42, _111) + in call 'erlang':'and' + (_26, _112) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' -> + let = + call %% Line 694 + 'erlang':%% Line 694 + 'list_to_integer' + (%% Line 694 + [100|[A|[B|[C|[]]]]], %% Line 694 + 16) + in let = + call %% Line 695 + 'erlang':%% Line 695 + 'list_to_integer' + (%% Line 695 + [100|[X|[Y|[Z|[]]]]], %% Line 695 + 16) + in let <_116> = + call %% Line 696 + 'erlang':%% Line 696 + '-' + (%% Line 696 + High, %% Line 696 + 55296) + in let <_117> = + call %% Line 696 + 'erlang':%% Line 696 + '*' + (_116, %% Line 696 + 1024) + in let <_115> = + call %% Line 696 + 'erlang':%% Line 696 + '-' + (%% Line 696 + Low, %% Line 696 + 56320) + in let <_118> = + call %% Line 696 + 'erlang':%% Line 696 + '+' + (_117, _115) + in let = + call %% Line 696 + 'erlang':%% Line 696 + '+' + (_118, %% Line 696 + 65536) + in let <_120> = + #{#<%% Line 697 + Codepoint>(%% Line 697 + 'undefined','undefined','utf8',['unsigned'|['big']])}# + in %% Line 697 + apply 'string'/5 + (Rest, Handler, [Acc|[_120|[]]], Stack, Config) + %% Line 698 + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #<92>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> + when %% Line 699 + try + ( let <_131> = + case call 'erlang':'==' + (A, 56) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 57) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 98) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'==' + (A, 66) + -| ['compiler_generated'] ) + ( <_125> when 'true' -> + _125 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_124> when 'true' -> + _124 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_123> when 'true' -> + _123 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_122> when 'true' -> + _122 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_121> when 'true' -> + _121 + -| ['compiler_generated'] ) + end + in let <_132> = + call 'erlang':'=:=' + (( _131 + -| ['compiler_generated'] ), 'true') + in ( let <_135> = + case %% Line 700 + call 'erlang':'==' + (F0, 100) of + %% Line 700 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 700 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'==' + (F0, 68) + -| ['compiler_generated'] ) + %% Line 700 + ( <_133> when 'true' -> + _133 + -| ['compiler_generated'] ) + end + in let <_136> = + call 'erlang':'=:=' + (%% Line 700 + ( _135 + -| ['compiler_generated'] ), 'true') + in let <_140> = + case %% Line 701 + call 'erlang':'>=' + (B, 97) of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 102) + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 701 + ( <_138> when 'true' -> + _138 + -| ['compiler_generated'] ) + end + in ( let <_149> = + case _140 of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_144> = + case call 'erlang':'>=' + (B, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_142> when 'true' -> + _142 + -| ['compiler_generated'] ) + end + in ( case _144 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (B, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_145> when 'true' -> + _145 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_141> when 'true' -> + _141 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 701 + ( <_137> when 'true' -> + _137 + -| ['compiler_generated'] ) + end + in let <_150> = + call 'erlang':'=:=' + (%% Line 701 + ( _149 + -| ['compiler_generated'] ), 'true') + in let <_154> = + case %% Line 701 + call 'erlang':'>=' + (C, 97) of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 102) + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 701 + ( <_152> when 'true' -> + _152 + -| ['compiler_generated'] ) + end + in ( let <_163> = + case _154 of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_158> = + case call 'erlang':'>=' + (C, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_156> when 'true' -> + _156 + -| ['compiler_generated'] ) + end + in ( case _158 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (C, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_159> when 'true' -> + _159 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_155> when 'true' -> + _155 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 701 + ( <_151> when 'true' -> + _151 + -| ['compiler_generated'] ) + end + in let <_164> = + call 'erlang':'=:=' + (%% Line 701 + ( _163 + -| ['compiler_generated'] ), 'true') + in let <_168> = + case %% Line 701 + call 'erlang':'>=' + (W, 97) of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (W, 102) + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 701 + ( <_166> when 'true' -> + _166 + -| ['compiler_generated'] ) + end + in ( let <_177> = + case _168 of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_172> = + case call 'erlang':'>=' + (W, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (W, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_170> when 'true' -> + _170 + -| ['compiler_generated'] ) + end + in ( case _172 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (W, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (W, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_173> when 'true' -> + _173 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_169> when 'true' -> + _169 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 701 + ( <_165> when 'true' -> + _165 + -| ['compiler_generated'] ) + end + in let <_178> = + call 'erlang':'=:=' + (%% Line 701 + ( _177 + -| ['compiler_generated'] ), 'true') + in let <_182> = + case %% Line 701 + call 'erlang':'>=' + (X, 97) of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (X, 102) + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 701 + ( <_180> when 'true' -> + _180 + -| ['compiler_generated'] ) + end + in ( let <_191> = + case _182 of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_186> = + case call 'erlang':'>=' + (X, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (X, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_184> when 'true' -> + _184 + -| ['compiler_generated'] ) + end + in ( case _186 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (X, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (X, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_187> when 'true' -> + _187 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_183> when 'true' -> + _183 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 701 + ( <_179> when 'true' -> + _179 + -| ['compiler_generated'] ) + end + in let <_192> = + call 'erlang':'=:=' + (%% Line 701 + ( _191 + -| ['compiler_generated'] ), 'true') + in let <_196> = + case %% Line 701 + call 'erlang':'>=' + (Y, 97) of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Y, 102) + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 701 + ( <_194> when 'true' -> + _194 + -| ['compiler_generated'] ) + end + in ( let <_205> = + case _196 of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_200> = + case call 'erlang':'>=' + (Y, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Y, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_198> when 'true' -> + _198 + -| ['compiler_generated'] ) + end + in ( case _200 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (Y, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Y, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_201> when 'true' -> + _201 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_197> when 'true' -> + _197 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 701 + ( <_193> when 'true' -> + _193 + -| ['compiler_generated'] ) + end + in let <_206> = + call 'erlang':'=:=' + (%% Line 701 + ( _205 + -| ['compiler_generated'] ), 'true') + in let <_210> = + case %% Line 701 + call 'erlang':'>=' + (Z, 97) of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Z, 102) + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 701 + ( <_208> when 'true' -> + _208 + -| ['compiler_generated'] ) + end + in ( let <_219> = + case _210 of + %% Line 701 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 701 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_214> = + case call 'erlang':'>=' + (Z, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Z, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_212> when 'true' -> + _212 + -| ['compiler_generated'] ) + end + in ( case _214 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (Z, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (Z, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_215> when 'true' -> + _215 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_211> when 'true' -> + _211 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 701 + ( <_207> when 'true' -> + _207 + -| ['compiler_generated'] ) + end + in let <_220> = + call 'erlang':'=:=' + (%% Line 701 + ( _219 + -| ['compiler_generated'] ), 'true') + in let <_221> = + call 'erlang':'and' + (_206, _220) + in let <_222> = + call 'erlang':'and' + (_192, _221) + in let <_223> = + call 'erlang':'and' + (_178, _222) + in let <_224> = + call 'erlang':'and' + (_164, _223) + in let <_225> = + call 'erlang':'and' + (_150, _224) + in let <_226> = + call 'erlang':'and' + (_136, _225) + in call 'erlang':'and' + (_132, _226) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' -> + %% Line 703 + ( case Config of + ( <( {'config',_462,_463,_464,_465,_466,_467,_rec13,_468,_469,_470,_471,_472,_473,_474,_475,_476} + -| ['compiler_generated'] )> when 'true' -> + case _rec13 of + %% Line 704 + <'true'> when 'true' -> + ( case Config of + ( <( {'config',_478,_479,_480,_481,_482,_483,_484,_485,_486,_487,_488,_489,_490,_491,_rec14,_492} + -| ['compiler_generated'] )> when 'true' -> + case _rec14 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_232> = + #{#<117>(8,1,'integer',['unsigned'|['big']]), + #<100>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #<92>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}# + in let <_231> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (_232, {'decoder','string',Handler,Acc,Stack}, _231) + end + -| ['compiler_generated'] ) + ( <_493> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 705 + <'false'> when 'true' -> + apply 'string'/5 + (Rest, Handler, [Acc|[#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<189>(8,1,'integer',['unsigned'|['big']])}#|[#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<189>(8,1,'integer',['unsigned'|['big']])}#]]], Stack, Config) + ( <_234> when 'true' -> + primop 'match_fail' + ({'case_clause',_234}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_477> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 707 + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #<92>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> + when %% Line 708 + try + ( let <_245> = + case call 'erlang':'==' + (A, 56) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 57) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 98) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'==' + (A, 66) + -| ['compiler_generated'] ) + ( <_239> when 'true' -> + _239 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_238> when 'true' -> + _238 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_237> when 'true' -> + _237 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_236> when 'true' -> + _236 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_235> when 'true' -> + _235 + -| ['compiler_generated'] ) + end + in let <_246> = + call 'erlang':'=:=' + (( _245 + -| ['compiler_generated'] ), 'true') + in ( let <_249> = + case %% Line 709 + call 'erlang':'==' + (F, 100) of + %% Line 709 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 709 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'==' + (F, 68) + -| ['compiler_generated'] ) + %% Line 709 + ( <_247> when 'true' -> + _247 + -| ['compiler_generated'] ) + end + in let <_250> = + call 'erlang':'=:=' + (%% Line 709 + ( _249 + -| ['compiler_generated'] ), 'true') + in let <_254> = + case %% Line 710 + call 'erlang':'>=' + (B, 97) of + %% Line 710 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 102) + -| ['compiler_generated'] ) + %% Line 710 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 710 + ( <_252> when 'true' -> + _252 + -| ['compiler_generated'] ) + end + in ( let <_263> = + case _254 of + %% Line 710 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 710 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_258> = + case call 'erlang':'>=' + (B, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_256> when 'true' -> + _256 + -| ['compiler_generated'] ) + end + in ( case _258 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (B, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_259> when 'true' -> + _259 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_255> when 'true' -> + _255 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 710 + ( <_251> when 'true' -> + _251 + -| ['compiler_generated'] ) + end + in let <_264> = + call 'erlang':'=:=' + (%% Line 710 + ( _263 + -| ['compiler_generated'] ), 'true') + in let <_268> = + case %% Line 710 + call 'erlang':'>=' + (C, 97) of + %% Line 710 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 102) + -| ['compiler_generated'] ) + %% Line 710 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 710 + ( <_266> when 'true' -> + _266 + -| ['compiler_generated'] ) + end + in ( let <_277> = + case _268 of + %% Line 710 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 710 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_272> = + case call 'erlang':'>=' + (C, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_270> when 'true' -> + _270 + -| ['compiler_generated'] ) + end + in ( case _272 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (C, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_273> when 'true' -> + _273 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_269> when 'true' -> + _269 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 710 + ( <_265> when 'true' -> + _265 + -| ['compiler_generated'] ) + end + in let <_278> = + call 'erlang':'=:=' + (%% Line 710 + ( _277 + -| ['compiler_generated'] ), 'true') + in let <_279> = + call 'erlang':'and' + (_264, _278) + in let <_280> = + call 'erlang':'and' + (_250, _279) + in call 'erlang':'and' + (_246, _280) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' -> + let <_281> = + #{#<%% Line 712 + 92>(%% Line 712 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 712 + 117>(%% Line 712 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 712 + 100>(%% Line 712 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 712 + A>(%% Line 712 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 712 + B>(%% Line 712 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 712 + C>(%% Line 712 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 712 + 92>(%% Line 712 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 712 + Rest>(%% Line 712 + 'all',8,'binary',['unsigned'|['big']])}# + in %% Line 712 + apply 'incomplete'/6 + ('string', _281, Handler, Acc, Stack, Config) + %% Line 713 + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> + when %% Line 714 + try + ( let <_292> = + case call 'erlang':'==' + (A, 56) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 57) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 98) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'==' + (A, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'==' + (A, 66) + -| ['compiler_generated'] ) + ( <_286> when 'true' -> + _286 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_285> when 'true' -> + _285 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_284> when 'true' -> + _284 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_283> when 'true' -> + _283 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_282> when 'true' -> + _282 + -| ['compiler_generated'] ) + end + in let <_293> = + call 'erlang':'=:=' + (( _292 + -| ['compiler_generated'] ), 'true') + in ( let <_296> = + case %% Line 715 + call 'erlang':'==' + (F, 100) of + %% Line 715 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 715 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'==' + (F, 68) + -| ['compiler_generated'] ) + %% Line 715 + ( <_294> when 'true' -> + _294 + -| ['compiler_generated'] ) + end + in let <_297> = + call 'erlang':'=:=' + (%% Line 715 + ( _296 + -| ['compiler_generated'] ), 'true') + in let <_301> = + case %% Line 716 + call 'erlang':'>=' + (B, 97) of + %% Line 716 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 102) + -| ['compiler_generated'] ) + %% Line 716 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 716 + ( <_299> when 'true' -> + _299 + -| ['compiler_generated'] ) + end + in ( let <_310> = + case _301 of + %% Line 716 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 716 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_305> = + case call 'erlang':'>=' + (B, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_303> when 'true' -> + _303 + -| ['compiler_generated'] ) + end + in ( case _305 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (B, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_306> when 'true' -> + _306 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_302> when 'true' -> + _302 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 716 + ( <_298> when 'true' -> + _298 + -| ['compiler_generated'] ) + end + in let <_311> = + call 'erlang':'=:=' + (%% Line 716 + ( _310 + -| ['compiler_generated'] ), 'true') + in let <_315> = + case %% Line 716 + call 'erlang':'>=' + (C, 97) of + %% Line 716 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 102) + -| ['compiler_generated'] ) + %% Line 716 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + %% Line 716 + ( <_313> when 'true' -> + _313 + -| ['compiler_generated'] ) + end + in ( let <_324> = + case _315 of + %% Line 716 + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + %% Line 716 + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_319> = + case call 'erlang':'>=' + (C, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_317> when 'true' -> + _317 + -| ['compiler_generated'] ) + end + in ( case _319 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (C, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_320> when 'true' -> + _320 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_316> when 'true' -> + _316 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 716 + ( <_312> when 'true' -> + _312 + -| ['compiler_generated'] ) + end + in let <_325> = + call 'erlang':'=:=' + (%% Line 716 + ( _324 + -| ['compiler_generated'] ), 'true') + in let <_326> = + call 'erlang':'and' + (_311, _325) + in let <_327> = + call 'erlang':'and' + (_297, _326) + in call 'erlang':'and' + (_293, _327) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' -> + let <_328> = + #{#<%% Line 718 + 92>(%% Line 718 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 718 + 117>(%% Line 718 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 718 + 100>(%% Line 718 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 718 + A>(%% Line 718 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 718 + B>(%% Line 718 + 8,1,'integer',['unsigned'|['big']]), + #<%% Line 718 + C>(%% Line 718 + 8,1,'integer',['unsigned'|['big']])}# + in %% Line 718 + apply 'incomplete'/6 + ('string', _328, Handler, Acc, Stack, Config) + %% Line 719 + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,Stack,Config> + when %% Line 720 + try + let <_332> = + case call 'erlang':'>=' + (A, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 102) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_330> when 'true' -> + _330 + -| ['compiler_generated'] ) + end + in ( let <_341> = + case _332 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_336> = + case call 'erlang':'>=' + (A, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_334> when 'true' -> + _334 + -| ['compiler_generated'] ) + end + in ( case _336 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (A, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_337> when 'true' -> + _337 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_333> when 'true' -> + _333 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_329> when 'true' -> + _329 + -| ['compiler_generated'] ) + end + in let <_342> = + call 'erlang':'=:=' + (( _341 + -| ['compiler_generated'] ), 'true') + in let <_346> = + case call 'erlang':'>=' + (B, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 102) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_344> when 'true' -> + _344 + -| ['compiler_generated'] ) + end + in ( let <_355> = + case _346 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_350> = + case call 'erlang':'>=' + (B, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_348> when 'true' -> + _348 + -| ['compiler_generated'] ) + end + in ( case _350 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (B, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_351> when 'true' -> + _351 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_347> when 'true' -> + _347 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_343> when 'true' -> + _343 + -| ['compiler_generated'] ) + end + in let <_356> = + call 'erlang':'=:=' + (( _355 + -| ['compiler_generated'] ), 'true') + in let <_360> = + case call 'erlang':'>=' + (C, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 102) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_358> when 'true' -> + _358 + -| ['compiler_generated'] ) + end + in ( let <_369> = + case _360 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_364> = + case call 'erlang':'>=' + (C, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_362> when 'true' -> + _362 + -| ['compiler_generated'] ) + end + in ( case _364 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (C, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_365> when 'true' -> + _365 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_361> when 'true' -> + _361 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_357> when 'true' -> + _357 + -| ['compiler_generated'] ) + end + in let <_370> = + call 'erlang':'=:=' + (( _369 + -| ['compiler_generated'] ), 'true') + in let <_374> = + case call 'erlang':'>=' + (D, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (D, 102) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_372> when 'true' -> + _372 + -| ['compiler_generated'] ) + end + in ( let <_383> = + case _374 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_378> = + case call 'erlang':'>=' + (D, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (D, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_376> when 'true' -> + _376 + -| ['compiler_generated'] ) + end + in ( case _378 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (D, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (D, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_379> when 'true' -> + _379 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_375> when 'true' -> + _375 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_371> when 'true' -> + _371 + -| ['compiler_generated'] ) + end + in let <_384> = + call 'erlang':'=:=' + (( _383 + -| ['compiler_generated'] ), 'true') + in let <_385> = + call 'erlang':'and' + (_370, _384) + in let <_386> = + call 'erlang':'and' + (_356, _385) + in call 'erlang':'and' + (_342, _386) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' -> + %% Line 721 + case call 'erlang':'list_to_integer' + ([A|[B|[C|[D|[]]]]], 16) of + %% Line 722 + + when let <_387> = + call 'erlang':'<' + (Codepoint, 55296) + in let <_388> = + call 'erlang':'>' + (Codepoint, 57343) + in call 'erlang':'or' + (_387, _388) -> + let <_389> = + case %% Line 723 + of + %% Line 746 + ( <_602,( {( 'config' + -| ['compiler_generated'] ),( 'true' + -| ['compiler_generated'] ),_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{( #<_602>(( 8 + -| ['compiler_generated'] ),( 1 + -| ['compiler_generated'] ),( 'integer' + -| ['compiler_generated'] ),( ['unsigned'|['big']] + -| ['compiler_generated'] )) + -| ['compiler_generated'] )}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 747 + ( <( 8 + -| ['compiler_generated'] ),( {( 'config' + -| ['compiler_generated'] ),_27,_28,( 'true' + -| ['compiler_generated'] ),_29,_30,_31,_32,_33,_34,_35,_36,_37,_38,_39,_40,_41} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<98>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 748 + ( <( 9 + -| ['compiler_generated'] ),( {( 'config' + -| ['compiler_generated'] ),_42,_43,( 'true' + -| ['compiler_generated'] ),_44,_45,_46,_47,_48,_49,_50,_51,_52,_53,_54,_55,_56} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<116>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 749 + ( <( 10 + -| ['compiler_generated'] ),( {( 'config' + -| ['compiler_generated'] ),_57,_58,( 'true' + -| ['compiler_generated'] ),_59,_60,_61,_62,_63,_64,_65,_66,_67,_68,_69,_70,_71} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<110>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 750 + ( <( 12 + -| ['compiler_generated'] ),( {( 'config' + -| ['compiler_generated'] ),_72,_73,( 'true' + -| ['compiler_generated'] ),_74,_75,_76,_77,_78,_79,_80,_81,_82,_83,_84,_85,_86} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<102>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 751 + ( <( 13 + -| ['compiler_generated'] ),( {( 'config' + -| ['compiler_generated'] ),_87,_88,( 'true' + -| ['compiler_generated'] ),_89,_90,_91,_92,_93,_94,_95,_96,_97,_98,_99,_100,_101} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<114>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 752 + ( <( 34 + -| ['compiler_generated'] ),( {( 'config' + -| ['compiler_generated'] ),_102,_103,( 'true' + -| ['compiler_generated'] ),_104,_105,_106,_107,_108,_109,_110,_111,_112,_113,_114,_115,_116} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<34>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 753 + ( <( 47 + -| ['compiler_generated'] ),( _603 = ( {( 'config' + -| ['compiler_generated'] ),_117,_118,( 'true' + -| ['compiler_generated'] ),_119,_120,_121,_122,_123,_124,_125,_126,_127,_128,_129,_130,_131} + -| ['compiler_generated'] ) + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 754 + ( case _603 of + ( <( {( 'config' + -| ['compiler_generated'] ),_132,_rec18,_133,_134,_135,_136,_137,_138,_139,_140,_141,_142,_143,_144,_145,_146} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( case _rec18 of + %% Line 755 + ( <( 'true' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 756 + ( <( 'false' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<47>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_605> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'case_clause' + -| ['compiler_generated'] ),_605} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_147> when ( 'true' + -| ['compiler_generated'] ) -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 758 + ( <( 92 + -| ['compiler_generated'] ),( {( 'config' + -| ['compiler_generated'] ),_148,_149,( 'true' + -| ['compiler_generated'] ),_150,_151,_152,_153,_154,_155,_156,_157,_158,_159,_160,_161,_162} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<92>(8,1,'integer',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 759 + ( + when ( let <_5> = + call ( 'erlang' + -| ['compiler_generated'] ):( '==' + -| ['compiler_generated'] ) + (X, ( 8232 + -| ['compiler_generated'] )) + in ( let <_6> = + call ( 'erlang' + -| ['compiler_generated'] ):( '==' + -| ['compiler_generated'] ) + (X, ( 8233 + -| ['compiler_generated'] )) + in ( call ( 'erlang' + -| ['compiler_generated'] ):( 'or' + -| ['compiler_generated'] ) + (_5, _6) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) -> + %% Line 760 + ( case _607 of + ( <( {( 'config' + -| ['compiler_generated'] ),_178,_179,_180,_181,_182,_183,_184,_185,_186,_187,_188,_189,_190,_rec19,_191,_192} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( case _rec19 of + %% Line 761 + ( <( 'true' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( #{( #(( 'undefined' + -| ['compiler_generated'] ),( 'undefined' + -| ['compiler_generated'] ),( 'utf8' + -| ['compiler_generated'] ),( ['unsigned'|['big']] + -| ['compiler_generated'] )) + -| ['compiler_generated'] )}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 762 + ( <( 'false' + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( apply 'json_escape_sequence'/1 + (X) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_9> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'case_clause' + -| ['compiler_generated'] ),_9} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_193> when ( 'true' + -| ['compiler_generated'] ) -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 764 + ( + when ( call ( 'erlang' + -| ['compiler_generated'] ):( '<' + -| ['compiler_generated'] ) + (X, + ( 32 + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) -> + %% Line 765 + ( apply 'json_escape_sequence'/1 + (X) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 766 + ( when ( 'true' + -| ['compiler_generated'] ) -> + ( #{( #(( 'undefined' + -| ['compiler_generated'] ),( 'undefined' + -| ['compiler_generated'] ),( 'utf8' + -| ['compiler_generated'] ),( ['unsigned'|['big']] + -| ['compiler_generated'] )) + -| ['compiler_generated'] )}# + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in %% Line 723 + apply 'string'/5 + (Rest, Handler, [Acc|[_389|[]]], Stack, Config) + %% Line 724 + <_494> + when ( try + ( let <_392> = + case ( call ( 'erlang' + -| ['compiler_generated'] ):( 'is_record' + -| ['compiler_generated'] ) + (Config, ( 'config' + -| ['compiler_generated'] ), ( 17 + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + ( 'true' + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( 'fail' + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <( _390 + -| ['compiler_generated'] )> when 'true' -> + ( _390 + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in let <_393> = + call 'erlang':'=:=' + (( _392 + -| ['compiler_generated'] ), 'true') + in let <_394> = + call 'erlang':'element' + (8, Config) + in let <_395> = + call 'erlang':'=:=' + (_394, 'true') + in ( call ( 'erlang' + -| ['compiler_generated'] ):( 'and' + -| ['compiler_generated'] ) + (_393, _395) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + %% Line 725 + ( case Config of + ( <( {'config',_495,_496,_497,_498,_499,_500,_501,_502,_503,_504,_505,_506,_507,_508,_rec15,_509} + -| ['compiler_generated'] )> when 'true' -> + case _rec15 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_399> = + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}# + in let <_398> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (_399, {'decoder','string',Handler,Acc,Stack}, _398) + end + -| ['compiler_generated'] ) + ( <_510> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 726 + <_511> when 'true' -> + apply 'string'/5 + (Rest, Handler, [Acc|[#{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<189>(8,1,'integer',['unsigned'|['big']])}#]], Stack, Config) + end + %% Line 728 + when 'true' -> + %% Line 729 + case apply 'is_partial_escape'/1 + (Bin) of + %% Line 730 + <'true'> when 'true' -> + let <_402> = + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}# + in apply 'incomplete'/6 + ('string', _402, Handler, Acc, Stack, Config) + %% Line 731 + <'false'> when 'true' -> + ( case Config of + ( <( {'config',_512,_513,_514,_515,_516,_517,_518,_519,_rec16,_520,_521,_522,_523,_524,_525,_526} + -| ['compiler_generated'] )> when 'true' -> + case _rec16 of + %% Line 732 + <'true'> when 'true' -> + ( case Config of + ( <( {'config',_528,_529,_530,_531,_532,_533,_534,_535,_536,_537,_538,_539,_540,_541,_rec17,_542} + -| ['compiler_generated'] )> when 'true' -> + case _rec17 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_408> = + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}# + in let <_407> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (_408, {'decoder','string',Handler,Acc,Stack}, _407) + end + -| ['compiler_generated'] ) + ( <_543> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 733 + <'false'> when 'true' -> + apply 'string'/5 + (Bin, Handler, [Acc|[#{#<92>(8,1,'integer',['unsigned'|['big']])}#]], Stack, Config) + ( <_410> when 'true' -> + primop 'match_fail' + ({'case_clause',_410}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_527> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_411> when 'true' -> + primop 'match_fail' + ({'case_clause',_411}) + -| ['compiler_generated'] ) + end + end +'is_partial_escape'/1 = + %% Line 738 + fun (_0) -> + case _0 of + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']])}#> + when try + let <_4> = + case call 'erlang':'>=' + (A, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 102) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_2> when 'true' -> + _2 + -| ['compiler_generated'] ) + end + in ( let <_13> = + case _4 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_8> = + case call 'erlang':'>=' + (A, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_6> when 'true' -> + _6 + -| ['compiler_generated'] ) + end + in ( case _8 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (A, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_9> when 'true' -> + _9 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5> when 'true' -> + _5 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_1> when 'true' -> + _1 + -| ['compiler_generated'] ) + end + in let <_14> = + call 'erlang':'=:=' + (( _13 + -| ['compiler_generated'] ), 'true') + in let <_18> = + case call 'erlang':'>=' + (B, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 102) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_16> when 'true' -> + _16 + -| ['compiler_generated'] ) + end + in ( let <_27> = + case _18 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_22> = + case call 'erlang':'>=' + (B, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_20> when 'true' -> + _20 + -| ['compiler_generated'] ) + end + in ( case _22 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (B, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_23> when 'true' -> + _23 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_19> when 'true' -> + _19 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_15> when 'true' -> + _15 + -| ['compiler_generated'] ) + end + in let <_28> = + call 'erlang':'=:=' + (( _27 + -| ['compiler_generated'] ), 'true') + in let <_32> = + case call 'erlang':'>=' + (C, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 102) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_30> when 'true' -> + _30 + -| ['compiler_generated'] ) + end + in ( let <_41> = + case _32 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_36> = + case call 'erlang':'>=' + (C, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_34> when 'true' -> + _34 + -| ['compiler_generated'] ) + end + in ( case _36 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (C, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (C, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_37> when 'true' -> + _37 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_33> when 'true' -> + _33 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_29> when 'true' -> + _29 + -| ['compiler_generated'] ) + end + in let <_42> = + call 'erlang':'=:=' + (( _41 + -| ['compiler_generated'] ), 'true') + in let <_43> = + call 'erlang':'and' + (_28, _42) + in call 'erlang':'and' + (_14, _43) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' -> + 'true' + %% Line 739 + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']])}#> + when try + let <_47> = + case call 'erlang':'>=' + (A, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 102) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_45> when 'true' -> + _45 + -| ['compiler_generated'] ) + end + in ( let <_56> = + case _47 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_51> = + case call 'erlang':'>=' + (A, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_49> when 'true' -> + _49 + -| ['compiler_generated'] ) + end + in ( case _51 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (A, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_52> when 'true' -> + _52 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_48> when 'true' -> + _48 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_44> when 'true' -> + _44 + -| ['compiler_generated'] ) + end + in let <_57> = + call 'erlang':'=:=' + (( _56 + -| ['compiler_generated'] ), 'true') + in let <_61> = + case call 'erlang':'>=' + (B, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 102) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_59> when 'true' -> + _59 + -| ['compiler_generated'] ) + end + in ( let <_70> = + case _61 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_65> = + case call 'erlang':'>=' + (B, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_63> when 'true' -> + _63 + -| ['compiler_generated'] ) + end + in ( case _65 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (B, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (B, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_66> when 'true' -> + _66 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_62> when 'true' -> + _62 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_58> when 'true' -> + _58 + -| ['compiler_generated'] ) + end + in let <_71> = + call 'erlang':'=:=' + (( _70 + -| ['compiler_generated'] ), 'true') + in call 'erlang':'and' + (_57, _71) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' -> + 'true' + %% Line 740 + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']])}#> + when try + let <_75> = + case call 'erlang':'>=' + (A, 97) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 102) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_73> when 'true' -> + _73 + -| ['compiler_generated'] ) + end + in ( let <_84> = + case _75 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + let <_79> = + case call 'erlang':'>=' + (A, 65) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 70) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_77> when 'true' -> + _77 + -| ['compiler_generated'] ) + end + in ( case _79 of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + 'true' + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( case call 'erlang':'>=' + (A, 48) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=<' + (A, 57) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_80> when 'true' -> + _80 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_76> when 'true' -> + _76 + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_72> when 'true' -> + _72 + -| ['compiler_generated'] ) + end + in ( call 'erlang':'=:=' + (( _84 + -| ['compiler_generated'] ), 'true') + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' -> + 'true' + %% Line 741 + <#{#<117>(8,1,'integer',['unsigned'|['big']])}#> when 'true' -> + 'true' + %% Line 742 + <#{}#> when 'true' -> + 'true' + %% Line 743 + <_86> when 'true' -> + 'false' + end +'maybe_replace'/2 = + %% Line 746 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + #{#(8,1,'integer',['unsigned'|['big']])}# + %% Line 747 + <8,{'config',_27,_28,'true',_29,_30,_31,_32,_33,_34,_35,_36,_37,_38,_39,_40,_41}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<98>(8,1,'integer',['unsigned'|['big']])}# + %% Line 748 + <9,{'config',_42,_43,'true',_44,_45,_46,_47,_48,_49,_50,_51,_52,_53,_54,_55,_56}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<116>(8,1,'integer',['unsigned'|['big']])}# + %% Line 749 + <10,{'config',_57,_58,'true',_59,_60,_61,_62,_63,_64,_65,_66,_67,_68,_69,_70,_71}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<110>(8,1,'integer',['unsigned'|['big']])}# + %% Line 750 + <12,{'config',_72,_73,'true',_74,_75,_76,_77,_78,_79,_80,_81,_82,_83,_84,_85,_86}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<102>(8,1,'integer',['unsigned'|['big']])}# + %% Line 751 + <13,{'config',_87,_88,'true',_89,_90,_91,_92,_93,_94,_95,_96,_97,_98,_99,_100,_101}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<114>(8,1,'integer',['unsigned'|['big']])}# + %% Line 752 + <34,{'config',_102,_103,'true',_104,_105,_106,_107,_108,_109,_110,_111,_112,_113,_114,_115,_116}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<34>(8,1,'integer',['unsigned'|['big']])}# + %% Line 753 + <47,Config = {'config',_117,_118,'true',_119,_120,_121,_122,_123,_124,_125,_126,_127,_128,_129,_130,_131}> when 'true' -> + %% Line 754 + ( case Config of + ( <( {'config',_132,_rec18,_133,_134,_135,_136,_137,_138,_139,_140,_141,_142,_143,_144,_145,_146} + -| ['compiler_generated'] )> when 'true' -> + case _rec18 of + %% Line 755 + <'true'> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']])}# + %% Line 756 + <'false'> when 'true' -> + #{#<47>(8,1,'integer',['unsigned'|['big']])}# + ( <_4> when 'true' -> + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_147> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 758 + <92,{'config',_148,_149,'true',_150,_151,_152,_153,_154,_155,_156,_157,_158,_159,_160,_161,_162}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<92>(8,1,'integer',['unsigned'|['big']])}# + %% Line 759 + + when let <_5> = + call 'erlang':'==' + (X, 8232) + in let <_6> = + call 'erlang':'==' + (X, 8233) + in call 'erlang':'or' + (_5, _6) -> + %% Line 760 + ( case Config of + ( <( {'config',_178,_179,_180,_181,_182,_183,_184,_185,_186,_187,_188,_189,_190,_rec19,_191,_192} + -| ['compiler_generated'] )> when 'true' -> + case _rec19 of + %% Line 761 + <'true'> when 'true' -> + #{#('undefined','undefined','utf8',['unsigned'|['big']])}# + %% Line 762 + <'false'> when 'true' -> + apply 'json_escape_sequence'/1 + (X) + ( <_9> when 'true' -> + primop 'match_fail' + ({'case_clause',_9}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_193> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 764 + + when call 'erlang':'<' + (X, + 32) -> + %% Line 765 + apply 'json_escape_sequence'/1 + (X) + %% Line 766 + when 'true' -> + #{#('undefined','undefined','utf8',['unsigned'|['big']])}# + end +'json_escape_sequence'/1 = + %% Line 770 + fun (_0) -> + case _0 of + + when call 'erlang':'<' + (_0, + 65536) -> + %% Line 771 + case #{#(16,1,'integer',['unsigned'|['big']])}# of + <#{#(4,1,'integer',['unsigned'|['big']]), + #(4,1,'integer',['unsigned'|['big']]), + #(4,1,'integer',['unsigned'|['big']]), + #(4,1,'integer',['unsigned'|['big']])}#> when 'true' -> + let <_5> = + apply %% Line 772 + 'to_hex'/1 + (%% Line 772 + A) + in let <_4> = + apply %% Line 772 + 'to_hex'/1 + (%% Line 772 + B) + in let <_3> = + apply %% Line 772 + 'to_hex'/1 + (%% Line 772 + C) + in let <_2> = + apply %% Line 772 + 'to_hex'/1 + (%% Line 772 + D) + in %% Line 772 + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']]), + #<_5>(8,1,'integer',['unsigned'|['big']]), + #<_4>(8,1,'integer',['unsigned'|['big']]), + #<_3>(8,1,'integer',['unsigned'|['big']]), + #<_2>(8,1,'integer',['unsigned'|['big']])}# + ( <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + -| ['compiler_generated'] ) + end + %% Line 773 + when 'true' -> + let = + call %% Line 774 + 'erlang':%% Line 774 + '-' + (%% Line 774 + X, %% Line 774 + 65536) + in %% Line 775 + case #{#(20,1,'integer',['unsigned'|['big']])}# of + <#{#(10,1,'integer',['unsigned'|['big']]), + #(10,1,'integer',['unsigned'|['big']])}#> when 'true' -> + let <_8> = + call %% Line 776 + 'erlang':%% Line 776 + '+' + (%% Line 776 + A, %% Line 776 + 55296) + in let <_9> = + apply %% Line 776 + 'json_escape_sequence'/1 + (_8) + in let <_10> = + call %% Line 776 + 'erlang':%% Line 776 + '+' + (%% Line 776 + B, %% Line 776 + 56320) + in let <_11> = + apply %% Line 776 + 'json_escape_sequence'/1 + (_10) + in %% Line 776 + [_9|[_11|[]]] + ( <_7> when 'true' -> + primop 'match_fail' + ({'badmatch',_7}) + -| ['compiler_generated'] ) + end + end +'to_hex'/1 = + %% Line 780 + fun (_0) -> + case _0 of + <10> when 'true' -> + 97 + %% Line 781 + <11> when 'true' -> + 98 + %% Line 782 + <12> when 'true' -> + 99 + %% Line 783 + <13> when 'true' -> + 100 + %% Line 784 + <14> when 'true' -> + 101 + %% Line 785 + <15> when 'true' -> + 102 + %% Line 786 + when 'true' -> + call 'erlang':'+' + (X, 48) + end +'number'/5 = + %% Line 789 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + <#{#<101>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,['integer'|Stack],Config> when 'true' -> + %% Line 790 + apply 'number'/5 + (Rest, Handler, [Acc|[46|[48|[101]]]], ['e'|Stack], Config) + %% Line 791 + <#{#<69>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,['integer'|Stack],Config> when 'true' -> + %% Line 792 + apply 'number'/5 + (Rest, Handler, [Acc|[46|[48|[101]]]], ['e'|Stack], Config) + %% Line 793 + <#{#<101>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,['zero'|Stack],Config> when 'true' -> + %% Line 794 + apply 'number'/5 + (Rest, Handler, [Acc|[46|[48|[101]]]], ['e'|Stack], Config) + %% Line 795 + <#{#<69>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Acc,['zero'|Stack],Config> when 'true' -> + %% Line 796 + apply 'number'/5 + (Rest, Handler, [Acc|[46|[48|[101]]]], ['e'|Stack], Config) + %% Line 797 + <#{}#,Handler,Acc,[State|Stack],Config = {'config',_28,_29,_30,_31,_32,_33,_34,_35,_36,_37,'false',_38,_39,_40,_41,_42}> when 'true' -> + let <_6> = + case %% Line 798 + State of + %% Line 799 + <'zero'> when 'true' -> + 'integer' + %% Line 800 + <'integer'> when 'true' -> + 'integer' + %% Line 801 + <'decimal'> when 'true' -> + 'float' + %% Line 802 + <'exp'> when 'true' -> + 'float' + ( <_5> when 'true' -> + %% Line 798 + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end + in let <_8> = + call %% Line 804 + 'erlang':%% Line 804 + 'iolist_to_binary' + (%% Line 804 + Acc) + in %% Line 804 + apply 'finish_number'/5 + (#{}#, Handler, {_6,_8}, Stack, Config) + %% Line 805 + <#{}#,Handler,Acc,Stack,Config> when 'true' -> + %% Line 806 + apply 'incomplete'/6 + ('number', #{}#, Handler, Acc, Stack, Config) + %% Line 807 + when 'true' -> + let <_10> = + case %% Line 808 + State of + %% Line 809 + <'zero'> when 'true' -> + apply 'zero'/2 + (Bin, 0) + %% Line 810 + <'integer'> when 'true' -> + apply 'integer'/2 + (Bin, 0) + %% Line 811 + <'negative'> when 'true' -> + apply 'negative'/2 + (Bin, 0) + %% Line 812 + <'initialdecimal'> when 'true' -> + apply 'initialdecimal'/2 + (Bin, 0) + %% Line 813 + <'decimal'> when 'true' -> + apply 'decimal'/2 + (Bin, 0) + %% Line 814 + <'e'> when 'true' -> + apply 'e'/2 + (Bin, 0) + %% Line 815 + <'ex'> when 'true' -> + apply 'ex'/2 + (Bin, 0) + %% Line 816 + <'exp'> when 'true' -> + apply 'exp'/2 + (Bin, 0) + ( <_9> when 'true' -> + %% Line 808 + primop 'match_fail' + ({'case_clause',_9}) + -| ['compiler_generated'] ) + end + in %% Line 818 + case _10 of + %% Line 819 + <{'finish_integer',Size}> when 'true' -> + %% Line 820 + case Bin of + <#{#(Size,8,'binary',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#> when 'true' -> + let <_13> = + call %% Line 821 + 'erlang':%% Line 821 + 'iolist_to_binary' + (%% Line 821 + [Acc|[Clean|[]]]) + in %% Line 821 + apply 'finish_number'/5 + (Rest, Handler, {'integer',_13}, Stack, Config) + ( <_12> when 'true' -> + primop 'match_fail' + ({'badmatch',_12}) + -| ['compiler_generated'] ) + end + %% Line 822 + <{'finish_float',Size}> when 'true' -> + %% Line 823 + case Bin of + <#{#(Size,8,'binary',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#> when 'true' -> + let <_15> = + call %% Line 824 + 'erlang':%% Line 824 + 'iolist_to_binary' + (%% Line 824 + [Acc|[Clean|[]]]) + in %% Line 824 + apply 'finish_number'/5 + (Rest, Handler, {'float',_15}, Stack, Config) + ( <_14> when 'true' -> + primop 'match_fail' + ({'badmatch',_14}) + -| ['compiler_generated'] ) + end + %% Line 825 + <{'error',Size}> when 'true' -> + %% Line 826 + case Bin of + <#{#(Size,8,'binary',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#> when 'true' -> + %% Line 827 + ( case Config of + ( <( {'config',_43,_44,_45,_46,_47,_48,_49,_50,_51,_52,_53,_54,_55,_56,_rec20,_57} + -| ['compiler_generated'] )> when 'true' -> + case _rec20 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_19> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Rest, {'decoder','number',Handler,[Acc|[Clean|[]]],Stack}, _19) + end + -| ['compiler_generated'] ) + ( <_58> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_16> when 'true' -> + primop 'match_fail' + ({'badmatch',_16}) + -| ['compiler_generated'] ) + end + %% Line 828 + <{NewState,Size}> when 'true' -> + %% Line 829 + case Bin of + <#{#(Size,8,'binary',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#> when 'true' -> + %% Line 830 + apply 'number'/5 + (Rest, Handler, [Acc|[Clean|[]]], [NewState|Stack], Config) + ( <_21> when 'true' -> + primop 'match_fail' + ({'badmatch',_21}) + -| ['compiler_generated'] ) + end + ( <_22> when 'true' -> + primop 'match_fail' + ({'case_clause',_22}) + -| ['compiler_generated'] ) + end + ( <_27,_26,_25,_24,_23> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_27,_26,_25,_24,_23}) + -| [{'function_name',{'number',5}}] ) + -| ['compiler_generated'] ) + end +'zero'/2 = + %% Line 834 + fun (_0,_1) -> + case <_0,_1> of + <#{#<46>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_2> = + call 'erlang':'+' + (N, 1) + in apply 'initialdecimal'/2 + (Rest, _2) + %% Line 835 + <#{#<101>(8,1,'integer',['unsigned'|['big']]), + #<_5>('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + {'integer',N} + %% Line 836 + <#{#<69>(8,1,'integer',['unsigned'|['big']]), + #<_6>('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + {'integer',N} + %% Line 837 + <#{}#,N> when 'true' -> + {'zero',N} + %% Line 838 + <_7,N> when 'true' -> + {'finish_integer',N} + end +'integer'/2 = + %% Line 841 + fun (_0,_1) -> + case <_0,_1> of + <#{#<48>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_2> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _2) + %% Line 842 + <#{#<49>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_3> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _3) + %% Line 843 + <#{#<50>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_4> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _4) + %% Line 844 + <#{#<51>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_5> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _5) + %% Line 845 + <#{#<52>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_6> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _6) + %% Line 846 + <#{#<53>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_7> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _7) + %% Line 847 + <#{#<54>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_8> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _8) + %% Line 848 + <#{#<55>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_9> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _9) + %% Line 849 + <#{#<56>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_10> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _10) + %% Line 850 + <#{#<57>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_11> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _11) + %% Line 851 + <#{#<46>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_12> = + call 'erlang':'+' + (N, 1) + in apply 'initialdecimal'/2 + (Rest, _12) + %% Line 852 + <#{#<101>(8,1,'integer',['unsigned'|['big']]), + #<_15>('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + {'integer',N} + %% Line 853 + <#{#<69>(8,1,'integer',['unsigned'|['big']]), + #<_16>('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + {'integer',N} + %% Line 854 + <#{}#,N> when 'true' -> + {'integer',N} + %% Line 855 + <_17,N> when 'true' -> + {'finish_integer',N} + end +'negative'/2 = + %% Line 858 + fun (_0,_1) -> + case <_0,_1> of + <#{#<48>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_2> = + call 'erlang':'+' + (N, 1) + in apply 'zero'/2 + (Rest, _2) + %% Line 859 + <#{#<49>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_3> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _3) + %% Line 860 + <#{#<50>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_4> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _4) + %% Line 861 + <#{#<51>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_5> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _5) + %% Line 862 + <#{#<52>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_6> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _6) + %% Line 863 + <#{#<53>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_7> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _7) + %% Line 864 + <#{#<54>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_8> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _8) + %% Line 865 + <#{#<55>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_9> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _9) + %% Line 866 + <#{#<56>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_10> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _10) + %% Line 867 + <#{#<57>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_11> = + call 'erlang':'+' + (N, 1) + in apply 'integer'/2 + (Rest, _11) + %% Line 868 + <#{}#,N> when 'true' -> + {'negative',N} + %% Line 869 + <_14,N> when 'true' -> + {'error',N} + end +'initialdecimal'/2 = + %% Line 872 + fun (_0,_1) -> + case <_0,_1> of + <#{#<48>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_2> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _2) + %% Line 873 + <#{#<49>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_3> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _3) + %% Line 874 + <#{#<50>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_4> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _4) + %% Line 875 + <#{#<51>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_5> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _5) + %% Line 876 + <#{#<52>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_6> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _6) + %% Line 877 + <#{#<53>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_7> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _7) + %% Line 878 + <#{#<54>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_8> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _8) + %% Line 879 + <#{#<55>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_9> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _9) + %% Line 880 + <#{#<56>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_10> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _10) + %% Line 881 + <#{#<57>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_11> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _11) + %% Line 882 + <#{}#,N> when 'true' -> + {'initialdecimal',N} + %% Line 883 + <_14,N> when 'true' -> + {'error',N} + end +'decimal'/2 = + %% Line 886 + fun (_0,_1) -> + case <_0,_1> of + <#{#<48>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_2> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _2) + %% Line 887 + <#{#<49>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_3> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _3) + %% Line 888 + <#{#<50>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_4> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _4) + %% Line 889 + <#{#<51>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_5> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _5) + %% Line 890 + <#{#<52>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_6> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _6) + %% Line 891 + <#{#<53>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_7> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _7) + %% Line 892 + <#{#<54>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_8> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _8) + %% Line 893 + <#{#<55>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_9> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _9) + %% Line 894 + <#{#<56>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_10> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _10) + %% Line 895 + <#{#<57>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_11> = + call 'erlang':'+' + (N, 1) + in apply 'decimal'/2 + (Rest, _11) + %% Line 896 + <#{#<101>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_12> = + call 'erlang':'+' + (N, 1) + in apply 'e'/2 + (Rest, _12) + %% Line 897 + <#{#<69>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_13> = + call 'erlang':'+' + (N, 1) + in apply 'e'/2 + (Rest, _13) + %% Line 898 + <#{}#,N> when 'true' -> + {'decimal',N} + %% Line 899 + <_16,N> when 'true' -> + {'finish_float',N} + end +'e'/2 = + %% Line 902 + fun (_0,_1) -> + case <_0,_1> of + <#{#<48>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_2> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _2) + %% Line 903 + <#{#<49>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_3> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _3) + %% Line 904 + <#{#<50>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_4> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _4) + %% Line 905 + <#{#<51>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_5> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _5) + %% Line 906 + <#{#<52>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_6> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _6) + %% Line 907 + <#{#<53>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_7> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _7) + %% Line 908 + <#{#<54>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_8> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _8) + %% Line 909 + <#{#<55>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_9> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _9) + %% Line 910 + <#{#<56>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_10> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _10) + %% Line 911 + <#{#<57>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_11> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _11) + %% Line 912 + <#{#<43>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_12> = + call 'erlang':'+' + (N, 1) + in apply 'ex'/2 + (Rest, _12) + %% Line 913 + <#{#<45>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_13> = + call 'erlang':'+' + (N, 1) + in apply 'ex'/2 + (Rest, _13) + %% Line 914 + <#{}#,N> when 'true' -> + {'e',N} + %% Line 915 + <_16,N> when 'true' -> + {'error',N} + end +'ex'/2 = + %% Line 918 + fun (_0,_1) -> + case <_0,_1> of + <#{#<48>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_2> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _2) + %% Line 919 + <#{#<49>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_3> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _3) + %% Line 920 + <#{#<50>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_4> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _4) + %% Line 921 + <#{#<51>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_5> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _5) + %% Line 922 + <#{#<52>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_6> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _6) + %% Line 923 + <#{#<53>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_7> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _7) + %% Line 924 + <#{#<54>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_8> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _8) + %% Line 925 + <#{#<55>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_9> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _9) + %% Line 926 + <#{#<56>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_10> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _10) + %% Line 927 + <#{#<57>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_11> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _11) + %% Line 928 + <#{}#,N> when 'true' -> + {'ex',N} + %% Line 929 + <_14,N> when 'true' -> + {'error',N} + end +'exp'/2 = + %% Line 932 + fun (_0,_1) -> + case <_0,_1> of + <#{#<48>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_2> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _2) + %% Line 933 + <#{#<49>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_3> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _3) + %% Line 934 + <#{#<50>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_4> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _4) + %% Line 935 + <#{#<51>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_5> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _5) + %% Line 936 + <#{#<52>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_6> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _6) + %% Line 937 + <#{#<53>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_7> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _7) + %% Line 938 + <#{#<54>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_8> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _8) + %% Line 939 + <#{#<55>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_9> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _9) + %% Line 940 + <#{#<56>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_10> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _10) + %% Line 941 + <#{#<57>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> when 'true' -> + let <_11> = + call 'erlang':'+' + (N, 1) + in apply 'exp'/2 + (Rest, _11) + %% Line 942 + <#{}#,N> when 'true' -> + {'exp',N} + %% Line 943 + <_14,N> when 'true' -> + {'finish_float',N} + end +'finish_number'/5 = + %% Line 946 + fun (_0,_1,_2,_3,_4) -> + let <_5> = + case _2 of + %% Line 951 + ( <( {( 'integer' + -| ['compiler_generated'] ),_13} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_14> = + call ( 'erlang' + -| ['compiler_generated'] ):( 'binary_to_integer' + -| ['compiler_generated'] ) + (_13) + in ( {( 'integer' + -| ['compiler_generated'] ),_14} + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + %% Line 952 + ( <( {( 'float' + -| ['compiler_generated'] ),_15} + -| ['compiler_generated'] )> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_16> = + call ( 'erlang' + -| ['compiler_generated'] ):( 'binary_to_float' + -| ['compiler_generated'] ) + (_15) + in ( {( 'float' + -| ['compiler_generated'] ),_16} + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_17> when ( 'true' + -| ['compiler_generated'] ) -> + %% Line 951 + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),_17} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in ( case <_5,_1,_4> of + ( when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_22> = + call _21:( 'handle_event' + -| ['compiler_generated'] ) + (Event, State) + in let <_6> = {_21,_22} + in %% Line 947 + apply 'maybe_done'/4 + (_0, _6, _3, _4) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_6,_23,_24> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),_6,_23,_24} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'format_number'/1 = + %% Line 951 + fun (_0) -> + case _0 of + <{'integer',Acc}> when 'true' -> + let <_1> = + call 'erlang':'binary_to_integer' + (Acc) + in {'integer',_1} + %% Line 952 + <{'float',Acc}> when 'true' -> + let <_2> = + call 'erlang':'binary_to_float' + (Acc) + in {'float',_2} + ( <_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3}) + -| [{'function_name',{'format_number',1}}] ) + -| ['compiler_generated'] ) + end +'true'/4 = + %% Line 959 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#<114>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']]), + #<101>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + ( case %% Line 960 + of + ( <( {_32,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_33> = + call _32:( 'handle_event' + -| ['compiler_generated'] ) + (( {'literal','true'} + -| ['compiler_generated'] ), State) + in let <_4> = {_32,_33} + in %% Line 960 + apply 'maybe_done'/4 + (Rest, _4, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( {'literal','true'} + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 961 + <#{#<114>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 962 + apply 'incomplete'/5 + ('true', #{#<114>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 963 + <#{#<114>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 964 + apply 'incomplete'/5 + ('true', #{#<114>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 965 + <#{}#,Handler,Stack,Config> when 'true' -> + %% Line 966 + apply 'incomplete'/5 + ('true', #{}#, Handler, Stack, Config) + %% Line 967 + when 'true' -> + %% Line 968 + ( case Config of + ( <( {'config',_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_rec21,_27} + -| ['compiler_generated'] )> when 'true' -> + case _rec21 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_7> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','true',Handler,'null',Stack}, _7) + end + -| ['compiler_generated'] ) + ( <_28> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'false'/4 = + %% Line 971 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#<97>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']]), + #<115>(8,1,'integer',['unsigned'|['big']]), + #<101>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + ( case %% Line 972 + of + ( <( {_32,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_33> = + call _32:( 'handle_event' + -| ['compiler_generated'] ) + (( {'literal','false'} + -| ['compiler_generated'] ), State) + in let <_4> = {_32,_33} + in %% Line 972 + apply 'maybe_done'/4 + (Rest, _4, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( {'literal','false'} + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 973 + <#{#<97>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']]), + #<115>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 974 + apply 'incomplete'/5 + ('false', #{#<97>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']]), + #<115>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 975 + <#{#<97>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 976 + apply 'incomplete'/5 + ('false', #{#<97>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 977 + <#{#<97>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 978 + apply 'incomplete'/5 + ('false', #{#<97>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 979 + <#{}#,Handler,Stack,Config> when 'true' -> + %% Line 980 + apply 'incomplete'/5 + ('false', #{}#, Handler, Stack, Config) + %% Line 981 + when 'true' -> + %% Line 982 + ( case Config of + ( <( {'config',_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_rec22,_27} + -| ['compiler_generated'] )> when 'true' -> + case _rec22 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_7> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','false',Handler,'null',Stack}, _7) + end + -| ['compiler_generated'] ) + ( <_28> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'null'/4 = + %% Line 985 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + ( case %% Line 986 + of + ( <( {_32,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_33> = + call _32:( 'handle_event' + -| ['compiler_generated'] ) + (( {'literal','null'} + -| ['compiler_generated'] ), State) + in let <_4> = {_32,_33} + in %% Line 986 + apply 'maybe_done'/4 + (Rest, _4, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( {'literal','null'} + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 987 + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 988 + apply 'incomplete'/5 + ('null', #{#<117>(8,1,'integer',['unsigned'|['big']]), + #<108>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 989 + <#{#<117>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 990 + apply 'incomplete'/5 + ('null', #{#<117>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 991 + <#{}#,Handler,Stack,Config> when 'true' -> + %% Line 992 + apply 'incomplete'/5 + ('null', #{}#, Handler, Stack, Config) + %% Line 993 + when 'true' -> + %% Line 994 + ( case Config of + ( <( {'config',_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_rec23,_27} + -| ['compiler_generated'] )> when 'true' -> + case _rec23 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_7> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','null',Handler,'null',Stack}, _7) + end + -| ['compiler_generated'] ) + ( <_28> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'comment'/5 = + %% Line 997 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + <#{#<10>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Resume,['comment'|Stack],Config> when 'true' -> + %% Line 998 + apply 'resume'/6 + (Rest, Resume, Handler, 'unused', Stack, Config) + %% Line 999 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<42>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Resume,Stack,Config> when 'true' -> + %% Line 1000 + apply 'comment'/5 + (Rest, Handler, Resume, ['multicomment'|Stack], Config) + %% Line 1001 + <#{#<47>(8,1,'integer',['unsigned'|['big']])}#,Handler,Resume,Stack = ['multicomment'|_17],Config> when 'true' -> + %% Line 1002 + apply 'incomplete'/6 + ('comment', #{#<47>(8,1,'integer',['unsigned'|['big']])}#, Handler, Resume, Stack, Config) + %% Line 1003 + <#{#<42>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Resume,['multicomment'|Stack],Config> when 'true' -> + %% Line 1004 + case Stack of + %% Line 1005 + <['multicomment'|_18]> when 'true' -> + apply 'comment'/5 + (Rest, Handler, Resume, Stack, Config) + %% Line 1006 + <_19> when 'true' -> + apply 'resume'/6 + (Rest, Resume, Handler, 'unused', Stack, Config) + end + %% Line 1008 + <#{#<42>(8,1,'integer',['unsigned'|['big']])}#,Handler,Resume,Stack = ['multicomment'|_20],Config> when 'true' -> + %% Line 1009 + apply 'incomplete'/6 + ('comment', #{#<42>(8,1,'integer',['unsigned'|['big']])}#, Handler, Resume, Stack, Config) + %% Line 1010 + <#{#<_21>('undefined','undefined','utf8',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Resume,Stack,Config> when 'true' -> + %% Line 1011 + apply 'comment'/5 + (Rest, Handler, Resume, Stack, Config) + %% Line 1012 + <#{#<_22>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Resume,Stack,Config = {'config',_23,_24,_25,_26,_27,_28,'false',_29,_30,_31,_32,_33,_34,_35,_36,_37}> when 'true' -> + %% Line 1013 + apply 'comment'/5 + (Rest, Handler, Resume, Stack, Config) + %% Line 1014 + <#{}#,Handler,'done',[Comment|[]],Config = {'config',_38,_39,_40,_41,_42,_43,_44,_45,_46,_47,'false',_48,_49,_50,_51,_52}> + when let <_6> = + call %% Line 1015 + 'erlang':%% Line 1015 + '=:=' + (%% Line 1015 + Comment, %% Line 1015 + 'comment') + in let <_7> = + call %% Line 1015 + 'erlang':%% Line 1015 + '=:=' + (%% Line 1015 + Comment, %% Line 1015 + 'multicomment') + in %% Line 1015 + call 'erlang':'or' + (_6, _7) -> + %% Line 1016 + apply 'resume'/6 + (#{}#, 'done', Handler, 'unused', [], Config) + %% Line 1017 + <#{}#,Handler,Resume,Stack,Config> when 'true' -> + %% Line 1018 + apply 'incomplete'/6 + ('comment', #{}#, Handler, Resume, Stack, Config) + %% Line 1019 + when 'true' -> + %% Line 1020 + ( case Config of + ( <( {'config',_53,_54,_55,_56,_57,_58,_59,_60,_61,_62,_63,_64,_65,_66,_rec24,_67} + -| ['compiler_generated'] )> when 'true' -> + case _rec24 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_10> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','comment',Handler,Resume,Stack}, _10) + end + -| ['compiler_generated'] ) + ( <_68> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'maybe_done'/4 = + %% Line 1023 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#('all',8,'binary',['unsigned'|['big']])}#,Handler,[],Config> when 'true' -> + ( case %% Line 1024 + of + ( <( {_72,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_73> = + call _72:( 'handle_event' + -| ['compiler_generated'] ) + (( 'end_json' + -| ['compiler_generated'] ), State) + in let <_4> = {_72,_73} + in %% Line 1024 + apply 'done'/4 + (Rest, _4, [], Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( 'end_json' + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 1025 + <#{#<32>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 1026 + apply 'maybe_done'/4 + (Rest, Handler, Stack, Config) + %% Line 1027 + <#{#<125>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,['object'|Stack],Config> when 'true' -> + ( case %% Line 1028 + of + ( <( {_77,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_78> = + call _77:( 'handle_event' + -| ['compiler_generated'] ) + (( 'end_object' + -| ['compiler_generated'] ), State) + in let <_5> = {_77,_78} + in %% Line 1028 + apply 'maybe_done'/4 + (Rest, _5, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( 'end_object' + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 1029 + <#{#<93>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,['array'|Stack],Config> when 'true' -> + ( case %% Line 1030 + of + ( <( {_82,State} + -| ['compiler_generated'] ),_X_Config> when ( 'true' + -| ['compiler_generated'] ) -> + ( let <_83> = + call _82:( 'handle_event' + -| ['compiler_generated'] ) + (( 'end_array' + -| ['compiler_generated'] ), State) + in let <_6> = {_82,_83} + in %% Line 1030 + apply 'maybe_done'/4 + (Rest, _6, Stack, Config) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_5,_4> when ( 'true' + -| ['compiler_generated'] ) -> + ( primop ( 'match_fail' + -| ['compiler_generated'] ) + (( {( 'function_clause' + -| ['compiler_generated'] ),( 'end_array' + -| ['compiler_generated'] ),_5,_4} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 1031 + <#{#<44>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,['object'|Stack],Config> when 'true' -> + %% Line 1032 + apply 'key'/4 + (Rest, Handler, ['key'|Stack], Config) + %% Line 1033 + <#{#<44>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack = ['array'|_21],Config> when 'true' -> + %% Line 1034 + apply 'value'/4 + (Rest, Handler, Stack, Config) + %% Line 1035 + <#{#<10>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 1036 + apply 'maybe_done'/4 + (Rest, Handler, Stack, Config) + %% Line 1037 + <#{#<9>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 1038 + apply 'maybe_done'/4 + (Rest, Handler, Stack, Config) + %% Line 1039 + <#{#<13>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 1040 + apply 'maybe_done'/4 + (Rest, Handler, Stack, Config) + %% Line 1041 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_22,_23,_24,_25,'true',_26,_27,_28,_29,_30,_31,_32,_33,_34,_35,_36}> when 'true' -> + %% Line 1042 + ( case Config of + ( <( {'config',_37,_38,_39,_40,_41,_42,_43,_44,_45,_46,_47,_48,_49,_50,_rec25,_51} + -| ['compiler_generated'] )> when 'true' -> + case _rec25 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_10> = + #{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}# + in let <_9> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (_10, {'decoder','maybe_done',Handler,'null',Stack}, _9) + end + -| ['compiler_generated'] ) + ( <_52> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 1043 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 1044 + apply 'comment'/5 + (Rest, Handler, 'maybe_done', ['comment'|Stack], Config) + %% Line 1045 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<42>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 1046 + apply 'comment'/5 + (Rest, Handler, 'maybe_done', ['multicomment'|Stack], Config) + %% Line 1047 + <#{#<47>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 1048 + apply 'incomplete'/5 + ('maybe_done', #{#<47>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 1049 + <#{}#,Handler,Stack,Config> + when try + let <_12> = + call 'erlang':'length' + (Stack) + in call 'erlang':'>' + (_12, 0) + of -> + Try + catch -> + 'false' -> + %% Line 1050 + apply 'incomplete'/5 + ('maybe_done', #{}#, Handler, Stack, Config) + %% Line 1051 + when 'true' -> + %% Line 1052 + ( case Config of + ( <( {'config',_53,_54,_55,_56,_57,_58,_59,_60,_61,_62,_63,_64,_65,_66,_rec26,_67} + -| ['compiler_generated'] )> when 'true' -> + case _rec26 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_15> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','maybe_done',Handler,'null',Stack}, _15) + end + -| ['compiler_generated'] ) + ( <_68> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'done'/4 = + %% Line 1055 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <#{#<32>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,[],Config> when 'true' -> + %% Line 1056 + apply 'done'/4 + (Rest, Handler, [], Config) + %% Line 1057 + <#{#<10>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,[],Config> when 'true' -> + %% Line 1058 + apply 'done'/4 + (Rest, Handler, [], Config) + %% Line 1059 + <#{#<9>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,[],Config> when 'true' -> + %% Line 1060 + apply 'done'/4 + (Rest, Handler, [], Config) + %% Line 1061 + <#{#<13>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,[],Config> when 'true' -> + %% Line 1062 + apply 'done'/4 + (Rest, Handler, [], Config) + %% Line 1063 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config = {'config',_18,_19,_20,_21,'true',_22,_23,_24,_25,_26,_27,_28,_29,_30,_31,_32}> when 'true' -> + %% Line 1064 + ( case Config of + ( <( {'config',_33,_34,_35,_36,_37,_38,_39,_40,_41,_42,_43,_44,_45,_46,_rec27,_47} + -| ['compiler_generated'] )> when 'true' -> + case _rec27 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_7> = + #{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}# + in let <_6> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (_7, {'decoder','done',Handler,'null',Stack}, _6) + end + -| ['compiler_generated'] ) + ( <_48> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 1065 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 1066 + apply 'comment'/5 + (Rest, Handler, 'done', ['comment'|Stack], Config) + %% Line 1067 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<42>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 1068 + apply 'comment'/5 + (Rest, Handler, 'done', ['multicomment'|Stack], Config) + %% Line 1069 + <#{#<47>(8,1,'integer',['unsigned'|['big']])}#,Handler,Stack,Config> when 'true' -> + %% Line 1070 + apply 'incomplete'/5 + ('done', #{#<47>(8,1,'integer',['unsigned'|['big']])}#, Handler, Stack, Config) + %% Line 1071 + when 'true' -> + %% Line 1072 + {'with_tail',State,Bin} + %% Line 1073 + <#{}#,_@r0 = {Handler,State},[],Config = {'config',_64,_65,_66,_67,_68,_69,_70,_71,_72,_73,'true',_74,_75,_76,_77,_78}> when 'true' -> + %% Line 1074 + apply 'incomplete'/5 + ('done', #{}#, _@r0, [], Config) + %% Line 1075 + <#{}#,{_X_Handler,State},[],_X_Config> when 'true' -> + State + %% Line 1076 + when 'true' -> + let <_9> = + call %% Line 1077 + Handler:%% Line 1077 + 'reset' + (%% Line 1077 + State) + in %% Line 1077 + apply 'value'/4 + (Bin, {Handler,_9}, [], Config) + %% Line 1078 + when 'true' -> + ( case Config of + ( <( {'config',_94,_95,_96,_97,_98,_99,_100,_101,_102,_103,_104,_105,_106,_107,_rec28,_108} + -| ['compiler_generated'] )> when 'true' -> + case _rec28 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_12> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (Bin, {'decoder','done',Handler,'null',Stack}, _12) + end + -| ['compiler_generated'] ) + ( <_109> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('jsx_decoder') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('jsx_decoder', _0) +end \ No newline at end of file diff --git a/test/data/jsx/jsx_decoder.erl b/test/data/jsx/jsx_decoder.erl new file mode 100644 index 0000000..9e0d205 --- /dev/null +++ b/test/data/jsx/jsx_decoder.erl @@ -0,0 +1,1916 @@ +%% The MIT License + +%% Copyright (c) 2010-2013 alisdair sullivan + +%% Permission is hereby granted, free of charge, to any person obtaining a copy +%% of this software and associated documentation files (the "Software"), to deal +%% in the Software without restriction, including without limitation the rights +%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%% copies of the Software, and to permit persons to whom the Software is +%% furnished to do so, subject to the following conditions: + +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. + +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +%% THE SOFTWARE. + + +-module(jsx_decoder). + +%% inline handle_event, format_number and maybe_replace +-compile({inline, [handle_event/3]}). +-compile({inline, [format_number/1]}). +-compile({inline, [maybe_replace/2]}). +-compile({inline, [doublequote/5, singlequote/5]}). + +-export([decoder/3, resume/6]). + + +-spec decoder(Handler::module(), State::any(), Config::list()) -> jsx:decoder(). + +decoder(Handler, State, Config) -> + fun(JSON) -> start(JSON, {Handler, Handler:init(State)}, [], jsx_config:parse_config(Config)) end. + + +%% resume allows continuation from interrupted decoding without having to explicitly export +%% all states +-spec resume( + Rest::binary(), + State::atom(), + Handler::module(), + Acc::any(), + Stack::list(atom()), + Config::jsx:config() + ) -> jsx:decoder() | {incomplete, jsx:decoder()}. + +resume(Rest, State, Handler, Acc, Stack, Config) -> + case State of + start -> start(Rest, Handler, Stack, Config); + value -> value(Rest, Handler, Stack, Config); + object -> object(Rest, Handler, Stack, Config); + array -> array(Rest, Handler, Stack, Config); + colon -> colon(Rest, Handler, Stack, Config); + key -> key(Rest, Handler, Stack, Config); + string -> string(Rest, Handler, Acc, Stack, Config); + number -> number(Rest, Handler, Acc, Stack, Config); + true -> true(Rest, Handler, Stack, Config); + false -> false(Rest, Handler, Stack, Config); + null -> null(Rest, Handler, Stack, Config); + comment -> comment(Rest, Handler, Acc, Stack, Config); + maybe_done -> maybe_done(Rest, Handler, Stack, Config); + done -> done(Rest, Handler, Stack, Config) + end. + + +-include("jsx_config.hrl"). + + +%% whitespace +-define(space, 16#20). +-define(tab, 16#09). +-define(cr, 16#0D). +-define(newline, 16#0A). + +%% object delimiters +-define(start_object, 16#7B). +-define(end_object, 16#7D). + +%% array delimiters +-define(start_array, 16#5B). +-define(end_array, 16#5D). + +%% kv seperator +-define(comma, 16#2C). +-define(doublequote, 16#22). +-define(singlequote, 16#27). +-define(colon, 16#3A). + +%% string escape sequences +-define(rsolidus, 16#5C). +-define(solidus, 16#2F). + +%% math +-define(zero, 16#30). +-define(decimalpoint, 16#2E). +-define(negative, 16#2D). +-define(positive, 16#2B). + +%% comments +-define(star, 16#2A). + + +%% some useful guards +-define(is_hex(Symbol), + (Symbol >= $a andalso Symbol =< $f) orelse + (Symbol >= $A andalso Symbol =< $F) orelse + (Symbol >= $0 andalso Symbol =< $9) +). + +-define(is_nonzero(Symbol), + Symbol >= $1 andalso Symbol =< $9 +). + + +%% error is a macro so the stack trace shows the error site when possible +-ifndef(error). +-define(error(State, Bin, Handler, Acc, Stack, Config), + case Config#config.error_handler of + false -> erlang:error(badarg); + F -> F(Bin, {decoder, State, Handler, Acc, Stack}, jsx_config:config_to_list(Config)) + end +). +-define(error(State, Bin, Handler, Stack, Config), + ?error(State, Bin, Handler, null, Stack, Config) +). +-endif. + + +incomplete(State, Rest, Handler, Stack, Config = #config{stream=false}) -> + ?error(State, Rest, Handler, Stack, Config); +incomplete(State, Rest, Handler, Stack, Config) -> + incomplete(State, Rest, Handler, unused, Stack, Config). + + +incomplete(State, Rest, Handler, Acc, Stack, Config = #config{stream=false}) -> + ?error(State, Rest, Handler, Acc, Stack, Config); +incomplete(State, Rest, Handler, Acc, Stack, Config = #config{incomplete_handler=false}) -> + {incomplete, fun(Stream) when is_binary(Stream) -> + resume(<>, State, Handler, Acc, Stack, Config); + (End) when End == end_stream; End == end_json -> + case resume(<>, State, Handler, Acc, Stack, Config#config{stream=false}) of + {incomplete, _} -> ?error(State, Rest, Handler, Acc, Stack, Config); + Else -> Else + end + end + }; +incomplete(State, Rest, Handler, Acc, Stack, Config = #config{incomplete_handler=F}) -> + F(Rest, {decoder, State, Handler, Acc, Stack}, jsx_config:config_to_list(Config)). + + +handle_event(Event, {Handler, State}, _Config) -> {Handler, Handler:handle_event(Event, State)}. + + +start(<<16#ef, 16#bb, 16#bf, Rest/binary>>, Handler, Stack, Config) -> + value(Rest, Handler, Stack, Config); +start(<<16#ef, 16#bb>>, Handler, Stack, Config) -> + incomplete(start, <<16#ef, 16#bb>>, Handler, Stack, Config); +start(<<16#ef>>, Handler, Stack, Config) -> + incomplete(start, <<16#ef>>, Handler, Stack, Config); +start(<<>>, Handler, Stack, Config) -> + incomplete(start, <<>>, Handler, Stack, Config); +start(Bin, Handler, Stack, Config) -> + value(Bin, Handler, Stack, Config). + + +value(<>, Handler, Stack, Config) -> + string(Rest, Handler, Stack, Config); +value(<>, Handler, Stack, Config) -> + value(Rest, Handler, Stack, Config); +value(<>, Handler, Stack, Config) -> + object(Rest, handle_event(start_object, Handler, Config), [key|Stack], Config); +value(<>, Handler, Stack, Config) -> + array(Rest, handle_event(start_array, Handler, Config), [array|Stack], Config); +value(<<$t, $r, $u, $e, Rest/binary>>, Handler, Stack, Config) -> + maybe_done(Rest, handle_event({literal, true}, Handler, Config), Stack, Config); +value(<<$f, $a, $l, $s, $e, Rest/binary>>, Handler, Stack, Config) -> + maybe_done(Rest, handle_event({literal, false}, Handler, Config), Stack, Config); +value(<<$n, $u, $l, $l, Rest/binary>>, Handler, Stack, Config) -> + maybe_done(Rest, handle_event({literal, null}, Handler, Config), Stack, Config); +value(<>, Handler, Stack, Config) -> + number(Rest, Handler, [?zero], [zero|Stack], Config); +value(<<$1, Rest/binary>>, Handler, Stack, Config) -> + number(Rest, Handler, [$1], [integer|Stack], Config); +value(<<$2, Rest/binary>>, Handler, Stack, Config) -> + number(Rest, Handler, [$2], [integer|Stack], Config); +value(<<$3, Rest/binary>>, Handler, Stack, Config) -> + number(Rest, Handler, [$3], [integer|Stack], Config); +value(<<$4, Rest/binary>>, Handler, Stack, Config) -> + number(Rest, Handler, [$4], [integer|Stack], Config); +value(<<$5, Rest/binary>>, Handler, Stack, Config) -> + number(Rest, Handler, [$5], [integer|Stack], Config); +value(<<$6, Rest/binary>>, Handler, Stack, Config) -> + number(Rest, Handler, [$6], [integer|Stack], Config); +value(<<$7, Rest/binary>>, Handler, Stack, Config) -> + number(Rest, Handler, [$7], [integer|Stack], Config); +value(<<$8, Rest/binary>>, Handler, Stack, Config) -> + number(Rest, Handler, [$8], [integer|Stack], Config); +value(<<$9, Rest/binary>>, Handler, Stack, Config) -> + number(Rest, Handler, [$9], [integer|Stack], Config); +value(<>, Handler, Stack, Config) -> + number(Rest, Handler, [$-], [negative|Stack], Config); +value(<>, Handler, Stack, Config) -> + value(Rest, Handler, Stack, Config); +value(<<$t, Rest/binary>>, Handler, Stack, Config) -> + true(Rest, Handler, Stack, Config); +value(<<$f, Rest/binary>>, Handler, Stack, Config) -> + false(Rest, Handler, Stack, Config); +value(<<$n, Rest/binary>>, Handler, Stack, Config) -> + null(Rest, Handler, Stack, Config); +value(<>, Handler, Stack, Config) -> + value(Rest, Handler, Stack, Config); +value(<>, Handler, Stack, Config) -> + value(Rest, Handler, Stack, Config); +value(<>, Handler, Stack, Config=#config{strict_single_quotes=false}) -> + string(Rest, Handler, [singlequote|Stack], Config); +value(<> = Rest, Handler, Stack, Config=#config{strict_commas=false}) -> + maybe_done(Rest, Handler, Stack, Config); +value(<>, Handler, Stack, Config=#config{strict_comments=true}) -> + ?error(value, <>, Handler, Stack, Config); +value(<>, Handler, Stack, Config) -> + comment(Rest, Handler, value, [comment|Stack], Config); +value(<>, Handler, Stack, Config) -> + comment(Rest, Handler, value, [multicomment|Stack], Config); +value(<>, Handler, Stack, Config) -> + incomplete(value, <>, Handler, Stack, Config); +value(<<>>, Handler, Stack, Config) -> + incomplete(value, <<>>, Handler, Stack, Config); +value(Bin, Handler, Stack, Config) -> + ?error(value, Bin, Handler, Stack, Config). + + +object(<>, Handler, Stack, Config) -> + string(Rest, Handler, Stack, Config); +object(<>, Handler, Stack, Config) -> + object(Rest, Handler, Stack, Config); +object(<>, Handler, [key|Stack], Config) -> + maybe_done(Rest, handle_event(end_object, Handler, Config), Stack, Config); +object(<>, Handler, Stack, Config) -> + object(Rest, Handler, Stack, Config); +object(<>, Handler, Stack, Config) -> + object(Rest, Handler, Stack, Config); +object(<>, Handler, Stack, Config) -> + object(Rest, Handler, Stack, Config); +object(<>, Handler, Stack, Config=#config{strict_single_quotes=false}) -> + string(Rest, Handler, [singlequote|Stack], Config); +object(<>, Handler, Stack, Config=#config{strict_comments=true}) -> + ?error(object, <>, Handler, Stack, Config); +object(<>, Handler, Stack, Config) -> + comment(Rest, Handler, object, [comment|Stack], Config); +object(<>, Handler, Stack, Config) -> + comment(Rest, Handler, object, [multicomment|Stack], Config); +object(<>, Handler, Stack, Config) -> + incomplete(object, <>, Handler, Stack, Config); +object(<<>>, Handler, Stack, Config) -> + incomplete(object, <<>>, Handler, Stack, Config); +object(Bin, Handler, Stack, Config) -> + ?error(object, Bin, Handler, Stack, Config). + + +array(<>, Handler, [array|Stack], Config) -> + maybe_done(Rest, handle_event(end_array, Handler, Config), Stack, Config); +array(<>, Handler, Stack, Config) -> + array(Rest, Handler, Stack, Config); +array(<>, Handler, Stack, Config) -> + array(Rest, Handler, Stack, Config); +array(<>, Handler, Stack, Config) -> + array(Rest, Handler, Stack, Config); +array(<>, Handler, Stack, Config) -> + array(Rest, Handler, Stack, Config); +array(<>, Handler, Stack, Config=#config{strict_comments=true}) -> + value(<>, Handler, Stack, Config); +array(<>, Handler, Stack, Config) -> + comment(Rest, Handler, array, [comment|Stack], Config); +array(<>, Handler, Stack, Config) -> + comment(Rest, Handler, array, [multicomment|Stack], Config); +array(<>, Handler, Stack, Config) -> + incomplete(array, <>, Handler, Stack, Config); +array(<<>>, Handler, Stack, Config) -> + incomplete(array, <<>>, Handler, Stack, Config); +array(Bin, Handler, Stack, Config) -> + value(Bin, Handler, Stack, Config). + + +colon(<>, Handler, [key|Stack], Config) -> + value(Rest, Handler, [object|Stack], Config); +colon(<>, Handler, Stack, Config) -> + colon(Rest, Handler, Stack, Config); +colon(<>, Handler, Stack, Config) -> + colon(Rest, Handler, Stack, Config); +colon(<>, Handler, Stack, Config) -> + colon(Rest, Handler, Stack, Config); +colon(<>, Handler, Stack, Config) -> + colon(Rest, Handler, Stack, Config); +colon(<>, Handler, Stack, Config=#config{strict_comments=true}) -> + ?error(colon, <>, Handler, Stack, Config); +colon(<>, Handler, Stack, Config) -> + comment(Rest, Handler, colon, [comment|Stack], Config); +colon(<>, Handler, Stack, Config) -> + comment(Rest, Handler, colon, [multicomment|Stack], Config); +colon(<>, Handler, Stack, Config) -> + incomplete(colon, <>, Handler, Stack, Config); +colon(<<>>, Handler, Stack, Config) -> + incomplete(colon, <<>>, Handler, Stack, Config); +colon(Bin, Handler, Stack, Config) -> + ?error(colon, Bin, Handler, Stack, Config). + + +key(<>, Handler, Stack, Config) -> + string(Rest, Handler, Stack, Config); +key(<>, Handler, Stack, Config) -> + key(Rest, Handler, Stack, Config); +key(<>, Handler, [key|Stack], Config=#config{strict_commas=false}) -> + maybe_done(<>, Handler, [object|Stack], Config); +key(<>, Handler, Stack, Config) -> + key(Rest, Handler, Stack, Config); +key(<>, Handler, Stack, Config) -> + key(Rest, Handler, Stack, Config); +key(<>, Handler, Stack, Config) -> + key(Rest, Handler, Stack, Config); +key(<>, Handler, Stack, Config=#config{strict_single_quotes=false}) -> + string(Rest, Handler, [singlequote|Stack], Config); +key(<>, Handler, Stack, Config=#config{strict_comments=true}) -> + ?error(key, <>, Handler, Stack, Config); +key(<>, Handler, Stack, Config) -> + comment(Rest, Handler, key, [comment|Stack], Config); +key(<>, Handler, Stack, Config) -> + comment(Rest, Handler, key, [multicomment|Stack], Config); +key(<>, Handler, Stack, Config) -> + incomplete(key, <>, Handler, Stack, Config); +key(<<>>, Handler, Stack, Config) -> + incomplete(key, <<>>, Handler, Stack, Config); +key(Bin, Handler, Stack, Config) -> + ?error(key, Bin, Handler, Stack, Config). + + +%% note that if you encounter an error from string and you can't find the clause that +%% caused it here, it might be in unescape below +string(Bin, Handler, Stack, Config) -> + string(Bin, Handler, [], Stack, Config). + + +string(<>, Handler, Acc, Stack, Config) -> + doublequote(Rest, Handler, Acc, Stack, Config); +string(<>, Handler, Acc, Stack, Config) -> + singlequote(Rest, Handler, Acc, Stack, Config); +string(<>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace(?solidus, Config)], Stack, Config); +string(<>, Handler, Acc, Stack, Config) -> + unescape(Rest, Handler, Acc, Stack, Config); +%% TODO this is pretty gross and i don't like it +string(<> = Bin, Handler, Acc, Stack, Config=#config{uescape=true}) -> + case X of + X when X < 16#80 -> count(Bin, Handler, Acc, Stack, Config); + X -> string(Rest, Handler, [Acc, json_escape_sequence(X)], Stack, Config) + end; +%% u+2028 +string(<<226, 128, 168, Rest/binary>>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace(16#2028, Config)], Stack, Config); +%% u+2029 +string(<<226, 128, 169, Rest/binary>>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace(16#2029, Config)], Stack, Config); +string(<> = Bin, Handler, Acc, Stack, Config=#config{strict_control_codes=true}) when X > 16#1f -> + count(Bin, Handler, Acc, Stack, Config); +string(<<_/utf8, _/binary>> = Bin, Handler, Acc, Stack, Config=#config{strict_control_codes=false}) -> + count(Bin, Handler, Acc, Stack, Config); +%% necessary for bytes that are badly formed utf8 that won't match in `count` +string(<>, Handler, Acc, Stack, Config=#config{dirty_strings=true}) -> + string(Rest, Handler, [Acc, X], Stack, Config); +%% u+fffe and u+ffff for R14BXX (subsequent runtimes will happily match with /utf8 +string(<<239, 191, 190, Rest/binary>>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, <<16#fffe/utf8>>], Stack, Config); +string(<<239, 191, 191, Rest/binary>>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, <<16#ffff/utf8>>], Stack, Config); +string(<<>>, Handler, Acc, Stack, Config) -> + incomplete(string, <<>>, Handler, Acc, Stack, Config); +string(<>, Handler, Acc, Stack, Config) when X >= 2#11000000 -> + incomplete(string, <>, Handler, Acc, Stack, Config); +string(<>, Handler, Acc, Stack, Config) when X >= 2#11100000, Y >= 2#10000000 -> + incomplete(string, <>, Handler, Acc, Stack, Config); +string(<>, Handler, Acc, Stack, Config) + when X >= 2#11100000, Y >= 2#10000000, Z >= 2#10000000 -> + incomplete(string, <>, Handler, Acc, Stack, Config); +%% surrogates +string(<<237, X, _, Rest/binary>>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) + when X >= 160 -> + string(Rest, Handler, [Acc, <<16#fffd/utf8>>], Stack, Config); +%% overlong encodings and missing continuations of a 2 byte sequence +string(<>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) + when X >= 192, X =< 223 -> + strip_continuations(Rest, Handler, Acc, Stack, Config, 1); +%% overlong encodings and missing continuations of a 3 byte sequence +string(<>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) + when X >= 224, X =< 239 -> + strip_continuations(Rest, Handler, Acc, Stack, Config, 2); +%% overlong encodings and missing continuations of a 4 byte sequence +string(<>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) + when X >= 240, X =< 247 -> + strip_continuations(Rest, Handler, Acc, Stack, Config, 3); +%% incompletes and unexpected bytes, including orphan continuations +string(<<_, Rest/binary>>, Handler, Acc, Stack, Config=#config{strict_utf8=false}) -> + string(Rest, Handler, [Acc, <<16#fffd/utf8>>], Stack, Config); +string(Bin, Handler, Acc, Stack, Config) -> ?error(string, Bin, Handler, Acc, Stack, Config). + + +count(Bin, Handler, Acc, Stack, Config) -> + Size = count(Bin, 0, Config), + <> = Bin, + string(Rest, Handler, [Acc, Clean], Stack, Config). + + +%% explicitly whitelist ascii set for faster parsing. really? really. someone should +%% submit a patch that unrolls simple guards +count(<<32, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<33, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<>, N, _) -> N; +count(<<35, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<36, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<37, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<38, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<>, N, _) -> N; +count(<<40, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<41, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<42, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<43, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<44, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<45, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<46, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<>, N, _) -> N; +count(<<48, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<49, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<50, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<51, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<52, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<53, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<54, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<55, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<56, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<57, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<58, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<59, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<60, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<61, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<62, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<63, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<64, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<65, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<66, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<67, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<68, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<69, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<70, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<71, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<72, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<73, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<74, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<75, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<76, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<77, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<78, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<79, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<80, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<81, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<82, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<83, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<84, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<85, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<86, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<87, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<88, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<89, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<90, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<91, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<>, N, _) -> N; +count(<<93, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<94, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<95, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<96, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<97, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<98, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<99, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<100, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<101, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<102, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<103, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<104, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<105, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<106, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<107, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<108, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<109, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<110, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<111, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<112, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<113, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<114, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<115, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<116, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<117, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<118, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<119, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<120, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<121, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<122, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<123, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<124, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<125, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<126, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<127, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<_, Rest/binary>>, N, Config=#config{dirty_strings=true}) -> + count(Rest, N + 1, Config); +count(<<_/utf8, _/binary>>, N, #config{uescape=true}) -> N; +count(<>, N, Config=#config{strict_control_codes=false}) when X < 32 -> + count(Rest, N + 1, Config); +count(<>, N, #config{strict_control_codes=true}) when X < 32 -> N; +count(<>, N, Config) -> + case X of + X when X < 16#800 -> count(Rest, N + 2, Config); + %% jsonp escaping + 16#2028 -> N; + 16#2029 -> N; + X when X < 16#10000 -> count(Rest, N + 3, Config); + _ -> count(Rest, N + 4, Config) + end; +count(_, N, _) -> N. + + +doublequote(Rest, Handler, Acc, [key|_] = Stack, Config) -> + colon(Rest, handle_event({key, iolist_to_binary(Acc)}, Handler, Config), Stack, Config); +doublequote(Rest, Handler, Acc, [singlequote|_] = Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace(?doublequote, Config)], Stack, Config); +doublequote(<<>>, Handler, Acc, [singlequote|_] = Stack, Config) -> + incomplete(string, <>, Handler, Acc, Stack, Config); +doublequote(Rest, Handler, Acc, Stack, Config) -> + maybe_done(Rest, handle_event({string, iolist_to_binary(Acc)}, Handler, Config), Stack, Config). + + +singlequote(Rest, Handler, Acc, [singlequote, key|Stack], Config) -> + colon(Rest, handle_event({key, iolist_to_binary(Acc)}, Handler, Config), [key|Stack], Config); +singlequote(Rest, Handler, Acc, [singlequote|Stack], Config) -> + maybe_done(Rest, handle_event({string, iolist_to_binary(Acc)}, Handler, Config), Stack, Config); +singlequote(Rest, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, ?singlequote], Stack, Config). + + +%% strips continuation bytes after bad utf bytes, guards against both too short +%% and overlong sequences. N is the maximum number of bytes to strip +strip_continuations(<>, Handler, Acc, Stack, Config, 0) -> + string(Rest, Handler, [Acc, <<16#fffd/utf8>>], Stack, Config); +strip_continuations(<>, Handler, Acc, Stack, Config, N) when X >= 128, X =< 191 -> + strip_continuations(Rest, Handler, Acc, Stack, Config, N - 1); +%% if end of input is reached before stripping the max number of continuations +%% possible magic numbers are reinserted into the stream that get us back to +%% the same state without complicated machinery +strip_continuations(<<>>, Handler, Acc, Stack, Config, N) -> + case N of + 1 -> incomplete(string, <<192>>, Handler, Acc, Stack, Config); + 2 -> incomplete(string, <<224>>, Handler, Acc, Stack, Config); + 3 -> incomplete(string, <<240>>, Handler, Acc, Stack, Config) + end; +%% not a continuation byte, insert a replacement character for sequence thus +%% far and dispatch back to string +strip_continuations(<>, Handler, Acc, Stack, Config, _) -> + string(Rest, Handler, [Acc, <<16#fffd/utf8>>], Stack, Config). + + +%% this all gets really gross and should probably eventually be folded into +%% but for now it fakes being part of string on incompletes and errors +unescape(<>, Handler, Acc, Stack, Config=#config{dirty_strings=true}) -> + string(<>, Handler, [Acc, <>], Stack, Config); +unescape(<>, Handler, Acc, Stack, Config=#config{dirty_strings=true}) -> + string(Rest, Handler, [Acc, <>], Stack, Config); +unescape(<<$b, Rest/binary>>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace($\b, Config)], Stack, Config); +unescape(<<$f, Rest/binary>>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace($\f, Config)], Stack, Config); +unescape(<<$n, Rest/binary>>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace($\n, Config)], Stack, Config); +unescape(<<$r, Rest/binary>>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace($\r, Config)], Stack, Config); +unescape(<<$t, Rest/binary>>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace($\t, Config)], Stack, Config); +unescape(<>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace($\", Config)], Stack, Config); +unescape(<>, Handler, Acc, Stack, Config=#config{strict_single_quotes=false}) -> + string(Rest, Handler, [Acc, <>], Stack, Config); +unescape(<>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace($\\, Config)], Stack, Config); +unescape(<>, Handler, Acc, Stack, Config) -> + string(Rest, Handler, [Acc, maybe_replace($/, Config)], Stack, Config); +unescape(<<$u, F, A, B, C, ?rsolidus, $u, G, X, Y, Z, Rest/binary>>, Handler, Acc, Stack, Config) + when (A == $8 orelse A == $9 orelse A == $a orelse A == $b orelse A == $A orelse A == $B), + (X == $c orelse X == $d orelse X == $e orelse X == $f orelse X == $C orelse X == $D orelse X == $E orelse X == $F), + (F == $d orelse F == $D), + (G == $d orelse G == $D), + ?is_hex(B), ?is_hex(C), ?is_hex(Y), ?is_hex(Z) + -> + High = erlang:list_to_integer([$d, A, B, C], 16), + Low = erlang:list_to_integer([$d, X, Y, Z], 16), + Codepoint = (High - 16#d800) * 16#400 + (Low - 16#dc00) + 16#10000, + string(Rest, Handler, [Acc, <>], Stack, Config); +unescape(<<$u, F0, A, B, C, ?rsolidus, $u, W, X, Y, Z, Rest/binary>>, Handler, Acc, Stack, Config) + when (A == $8 orelse A == $9 orelse A == $a orelse A == $b orelse A == $A orelse A == $B), + (F0 == $d orelse F0 == $D), + ?is_hex(B), ?is_hex(C), ?is_hex(W), ?is_hex(X), ?is_hex(Y), ?is_hex(Z) + -> + case Config#config.strict_utf8 of + true -> ?error(string, <<$u, $d, A, B, C, ?rsolidus, $u, W, X, Y, Z, Rest/binary>>, Handler, Acc, Stack, Config); + false -> string(Rest, Handler, [Acc, <<16#fffd/utf8>>, <<16#fffd/utf8>>], Stack, Config) + end; +unescape(<<$u, F, A, B, C, ?rsolidus, Rest/binary>>, Handler, Acc, Stack, Config) + when (A == $8 orelse A == $9 orelse A == $a orelse A == $b orelse A == $A orelse A == $B), + (F == $d orelse F == $D), + ?is_hex(B), ?is_hex(C) + -> + incomplete(string, <>, Handler, Acc, Stack, Config); +unescape(<<$u, F, A, B, C>>, Handler, Acc, Stack, Config) + when (A == $8 orelse A == $9 orelse A == $a orelse A == $b orelse A == $A orelse A == $B), + (F == $d orelse F == $D), + ?is_hex(B), ?is_hex(C) + -> + incomplete(string, <>, Handler, Acc, Stack, Config); +unescape(<<$u, A, B, C, D, Rest/binary>>, Handler, Acc, Stack, Config) + when ?is_hex(A), ?is_hex(B), ?is_hex(C), ?is_hex(D) -> + case erlang:list_to_integer([A, B, C, D], 16) of + Codepoint when Codepoint < 16#d800; Codepoint > 16#dfff -> + string(Rest, Handler, [Acc, maybe_replace(Codepoint, Config)], Stack, Config); + _ when Config#config.strict_utf8 -> + ?error(string, <>, Handler, Acc, Stack, Config); + _ -> string(Rest, Handler, [Acc, <<16#fffd/utf8>>], Stack, Config) + end; +unescape(Bin, Handler, Acc, Stack, Config) -> + case is_partial_escape(Bin) of + true -> incomplete(string, <>, Handler, Acc, Stack, Config); + false -> case Config#config.strict_escapes of + true -> ?error(string, <>, Handler, Acc, Stack, Config); + false -> string(Bin, Handler, [Acc, <>], Stack, Config) + end + end. + + +is_partial_escape(<<$u, A, B, C>>) when ?is_hex(A), ?is_hex(B), ?is_hex(C) -> true; +is_partial_escape(<<$u, A, B>>) when ?is_hex(A), ?is_hex(B) -> true; +is_partial_escape(<<$u, A>>) when ?is_hex(A) -> true; +is_partial_escape(<<$u>>) -> true; +is_partial_escape(<<>>) -> true; +is_partial_escape(_) -> false. + + +maybe_replace(C, #config{dirty_strings=true}) -> <>; +maybe_replace($\b, #config{escaped_strings=true}) -> <<$\\, $b>>; +maybe_replace($\t, #config{escaped_strings=true}) -> <<$\\, $t>>; +maybe_replace($\n, #config{escaped_strings=true}) -> <<$\\, $n>>; +maybe_replace($\f, #config{escaped_strings=true}) -> <<$\\, $f>>; +maybe_replace($\r, #config{escaped_strings=true}) -> <<$\\, $r>>; +maybe_replace($\", #config{escaped_strings=true}) -> <<$\\, $\">>; +maybe_replace($/, Config=#config{escaped_strings=true}) -> + case Config#config.escaped_forward_slashes of + true -> <<$\\, $/>> + ; false -> <<$/>> + end; +maybe_replace($\\, #config{escaped_strings=true}) -> <<$\\, $\\>>; +maybe_replace(X, Config=#config{escaped_strings=true}) when X == 16#2028; X == 16#2029 -> + case Config#config.unescaped_jsonp of + true -> <> + ; false -> json_escape_sequence(X) + end; +maybe_replace(X, #config{escaped_strings=true}) when X < 32 -> + json_escape_sequence(X); +maybe_replace(X, _Config) -> <>. + + +%% convert a codepoint to it's \uXXXX equiv. +json_escape_sequence(X) when X < 65536 -> + <> = <>, + <<$\\, $u, (to_hex(A)), (to_hex(B)), (to_hex(C)), (to_hex(D))>>; +json_escape_sequence(X) -> + Adjusted = X - 16#10000, + <> = <>, + [json_escape_sequence(A + 16#d800), json_escape_sequence(B + 16#dc00)]. + + +%% ascii "1" is [49], "2" is [50], etc... +to_hex(10) -> $a; +to_hex(11) -> $b; +to_hex(12) -> $c; +to_hex(13) -> $d; +to_hex(14) -> $e; +to_hex(15) -> $f; +to_hex(X) -> X + 48. + + +number(<<$e, Rest/binary>>, Handler, Acc, [integer|Stack], Config) -> + number(Rest, Handler, [Acc, $., $0, $e], [e|Stack], Config); +number(<<$E, Rest/binary>>, Handler, Acc, [integer|Stack], Config) -> + number(Rest, Handler, [Acc, $., $0, $e], [e|Stack], Config); +number(<<$e, Rest/binary>>, Handler, Acc, [zero|Stack], Config) -> + number(Rest, Handler, [Acc, $., $0, $e], [e|Stack], Config); +number(<<$E, Rest/binary>>, Handler, Acc, [zero|Stack], Config) -> + number(Rest, Handler, [Acc, $., $0, $e], [e|Stack], Config); +number(<<>>, Handler, Acc, [State|Stack], Config=#config{stream=false}) -> + NumType = case State of + zero -> integer; + integer -> integer; + decimal -> float; + exp -> float + end, + finish_number(<<>>, Handler, {NumType, iolist_to_binary(Acc)}, Stack, Config); +number(<<>>, Handler, Acc, Stack, Config) -> + incomplete(number, <<>>, Handler, Acc, Stack, Config); +number(Bin, Handler, Acc, [State|Stack], Config) -> + Counted = case State of + zero -> zero(Bin, 0); + integer -> integer(Bin, 0); + negative -> negative(Bin, 0); + initialdecimal -> initialdecimal(Bin, 0); + decimal -> decimal(Bin, 0); + e -> e(Bin, 0); + ex -> ex(Bin, 0); + exp -> exp(Bin, 0) + end, + case Counted of + {finish_integer, Size} -> + <> = Bin, + finish_number(Rest, Handler, {integer, iolist_to_binary([Acc, Clean])}, Stack, Config); + {finish_float, Size} -> + <> = Bin, + finish_number(Rest, Handler, {float, iolist_to_binary([Acc, Clean])}, Stack, Config); + {error, Size} -> + <> = Bin, + ?error(number, Rest, Handler, [Acc, Clean], Stack, Config); + {NewState, Size} -> + <> = Bin, + number(Rest, Handler, [Acc, Clean], [NewState|Stack], Config) + end. + + +zero(<>, N) -> initialdecimal(Rest, N + 1); +zero(<<$e, _/binary>>, N) -> {integer, N}; +zero(<<$E, _/binary>>, N) -> {integer, N}; +zero(<<>>, N) -> {zero, N}; +zero(_, N) -> {finish_integer, N}. + + +integer(<<$0, Rest/binary>>, N) -> integer(Rest, N + 1); +integer(<<$1, Rest/binary>>, N) -> integer(Rest, N + 1); +integer(<<$2, Rest/binary>>, N) -> integer(Rest, N + 1); +integer(<<$3, Rest/binary>>, N) -> integer(Rest, N + 1); +integer(<<$4, Rest/binary>>, N) -> integer(Rest, N + 1); +integer(<<$5, Rest/binary>>, N) -> integer(Rest, N + 1); +integer(<<$6, Rest/binary>>, N) -> integer(Rest, N + 1); +integer(<<$7, Rest/binary>>, N) -> integer(Rest, N + 1); +integer(<<$8, Rest/binary>>, N) -> integer(Rest, N + 1); +integer(<<$9, Rest/binary>>, N) -> integer(Rest, N + 1); +integer(<>, N) -> initialdecimal(Rest, N + 1); +integer(<<$e, _/binary>>, N) -> {integer, N}; +integer(<<$E, _/binary>>, N) -> {integer, N}; +integer(<<>>, N) -> {integer, N}; +integer(_, N) -> {finish_integer, N}. + + +negative(<<$0, Rest/binary>>, N) -> zero(Rest, N + 1); +negative(<<$1, Rest/binary>>, N) -> integer(Rest, N + 1); +negative(<<$2, Rest/binary>>, N) -> integer(Rest, N + 1); +negative(<<$3, Rest/binary>>, N) -> integer(Rest, N + 1); +negative(<<$4, Rest/binary>>, N) -> integer(Rest, N + 1); +negative(<<$5, Rest/binary>>, N) -> integer(Rest, N + 1); +negative(<<$6, Rest/binary>>, N) -> integer(Rest, N + 1); +negative(<<$7, Rest/binary>>, N) -> integer(Rest, N + 1); +negative(<<$8, Rest/binary>>, N) -> integer(Rest, N + 1); +negative(<<$9, Rest/binary>>, N) -> integer(Rest, N + 1); +negative(<<>>, N) -> {negative, N}; +negative(_, N) -> {error, N}. + + +initialdecimal(<<$0, Rest/binary>>, N) -> decimal(Rest, N + 1); +initialdecimal(<<$1, Rest/binary>>, N) -> decimal(Rest, N + 1); +initialdecimal(<<$2, Rest/binary>>, N) -> decimal(Rest, N + 1); +initialdecimal(<<$3, Rest/binary>>, N) -> decimal(Rest, N + 1); +initialdecimal(<<$4, Rest/binary>>, N) -> decimal(Rest, N + 1); +initialdecimal(<<$5, Rest/binary>>, N) -> decimal(Rest, N + 1); +initialdecimal(<<$6, Rest/binary>>, N) -> decimal(Rest, N + 1); +initialdecimal(<<$7, Rest/binary>>, N) -> decimal(Rest, N + 1); +initialdecimal(<<$8, Rest/binary>>, N) -> decimal(Rest, N + 1); +initialdecimal(<<$9, Rest/binary>>, N) -> decimal(Rest, N + 1); +initialdecimal(<<>>, N) -> {initialdecimal, N}; +initialdecimal(_, N) -> {error, N}. + + +decimal(<<$0, Rest/binary>>, N) -> decimal(Rest, N + 1); +decimal(<<$1, Rest/binary>>, N) -> decimal(Rest, N + 1); +decimal(<<$2, Rest/binary>>, N) -> decimal(Rest, N + 1); +decimal(<<$3, Rest/binary>>, N) -> decimal(Rest, N + 1); +decimal(<<$4, Rest/binary>>, N) -> decimal(Rest, N + 1); +decimal(<<$5, Rest/binary>>, N) -> decimal(Rest, N + 1); +decimal(<<$6, Rest/binary>>, N) -> decimal(Rest, N + 1); +decimal(<<$7, Rest/binary>>, N) -> decimal(Rest, N + 1); +decimal(<<$8, Rest/binary>>, N) -> decimal(Rest, N + 1); +decimal(<<$9, Rest/binary>>, N) -> decimal(Rest, N + 1); +decimal(<<$e, Rest/binary>>, N) -> e(Rest, N + 1); +decimal(<<$E, Rest/binary>>, N) -> e(Rest, N + 1); +decimal(<<>>, N) -> {decimal, N}; +decimal(_, N) -> {finish_float, N}. + + +e(<<$0, Rest/binary>>, N) -> exp(Rest, N + 1); +e(<<$1, Rest/binary>>, N) -> exp(Rest, N + 1); +e(<<$2, Rest/binary>>, N) -> exp(Rest, N + 1); +e(<<$3, Rest/binary>>, N) -> exp(Rest, N + 1); +e(<<$4, Rest/binary>>, N) -> exp(Rest, N + 1); +e(<<$5, Rest/binary>>, N) -> exp(Rest, N + 1); +e(<<$6, Rest/binary>>, N) -> exp(Rest, N + 1); +e(<<$7, Rest/binary>>, N) -> exp(Rest, N + 1); +e(<<$8, Rest/binary>>, N) -> exp(Rest, N + 1); +e(<<$9, Rest/binary>>, N) -> exp(Rest, N + 1); +e(<>, N) -> ex(Rest, N + 1); +e(<>, N) -> ex(Rest, N + 1); +e(<<>>, N) -> {e, N}; +e(_, N) -> {error, N}. + + +ex(<<$0, Rest/binary>>, N) -> exp(Rest, N + 1); +ex(<<$1, Rest/binary>>, N) -> exp(Rest, N + 1); +ex(<<$2, Rest/binary>>, N) -> exp(Rest, N + 1); +ex(<<$3, Rest/binary>>, N) -> exp(Rest, N + 1); +ex(<<$4, Rest/binary>>, N) -> exp(Rest, N + 1); +ex(<<$5, Rest/binary>>, N) -> exp(Rest, N + 1); +ex(<<$6, Rest/binary>>, N) -> exp(Rest, N + 1); +ex(<<$7, Rest/binary>>, N) -> exp(Rest, N + 1); +ex(<<$8, Rest/binary>>, N) -> exp(Rest, N + 1); +ex(<<$9, Rest/binary>>, N) -> exp(Rest, N + 1); +ex(<<>>, N) -> {ex, N}; +ex(_, N) -> {error, N}. + + +exp(<<$0, Rest/binary>>, N) -> exp(Rest, N + 1); +exp(<<$1, Rest/binary>>, N) -> exp(Rest, N + 1); +exp(<<$2, Rest/binary>>, N) -> exp(Rest, N + 1); +exp(<<$3, Rest/binary>>, N) -> exp(Rest, N + 1); +exp(<<$4, Rest/binary>>, N) -> exp(Rest, N + 1); +exp(<<$5, Rest/binary>>, N) -> exp(Rest, N + 1); +exp(<<$6, Rest/binary>>, N) -> exp(Rest, N + 1); +exp(<<$7, Rest/binary>>, N) -> exp(Rest, N + 1); +exp(<<$8, Rest/binary>>, N) -> exp(Rest, N + 1); +exp(<<$9, Rest/binary>>, N) -> exp(Rest, N + 1); +exp(<<>>, N) -> {exp, N}; +exp(_, N) -> {finish_float, N}. + + +finish_number(Rest, Handler, Acc, Stack, Config) -> + maybe_done(Rest, handle_event(format_number(Acc), Handler, Config), Stack, Config). + + +-ifndef(no_binary_to_whatever). +format_number({integer, Acc}) -> {integer, binary_to_integer(Acc)}; +format_number({float, Acc}) -> {float, binary_to_float(Acc)}. +-else. +format_number({integer, Acc}) -> {integer, list_to_integer(unicode:characters_to_list(Acc))}; +format_number({float, Acc}) -> {float, list_to_float(unicode:characters_to_list(Acc))}. +-endif. + + +true(<<$r, $u, $e, Rest/binary>>, Handler, Stack, Config) -> + maybe_done(Rest, handle_event({literal, true}, Handler, Config), Stack, Config); +true(<<$r, $u>>, Handler, Stack, Config) -> + incomplete(true, <<$r, $u>>, Handler, Stack, Config); +true(<<$r>>, Handler, Stack, Config) -> + incomplete(true, <<$r>>, Handler, Stack, Config); +true(<<>>, Handler, Stack, Config) -> + incomplete(true, <<>>, Handler, Stack, Config); +true(Bin, Handler, Stack, Config) -> + ?error(true, Bin, Handler, Stack, Config). + + +false(<<$a, $l, $s, $e, Rest/binary>>, Handler, Stack, Config) -> + maybe_done(Rest, handle_event({literal, false}, Handler, Config), Stack, Config); +false(<<$a, $l, $s>>, Handler, Stack, Config) -> + incomplete(false, <<$a, $l, $s>>, Handler, Stack, Config); +false(<<$a, $l>>, Handler, Stack, Config) -> + incomplete(false, <<$a, $l>>, Handler, Stack, Config); +false(<<$a>>, Handler, Stack, Config) -> + incomplete(false, <<$a>>, Handler, Stack, Config); +false(<<>>, Handler, Stack, Config) -> + incomplete(false, <<>>, Handler, Stack, Config); +false(Bin, Handler, Stack, Config) -> + ?error(false, Bin, Handler, Stack, Config). + + +null(<<$u, $l, $l, Rest/binary>>, Handler, Stack, Config) -> + maybe_done(Rest, handle_event({literal, null}, Handler, Config), Stack, Config); +null(<<$u, $l>>, Handler, Stack, Config) -> + incomplete(null, <<$u, $l>>, Handler, Stack, Config); +null(<<$u>>, Handler, Stack, Config) -> + incomplete(null, <<$u>>, Handler, Stack, Config); +null(<<>>, Handler, Stack, Config) -> + incomplete(null, <<>>, Handler, Stack, Config); +null(Bin, Handler, Stack, Config) -> + ?error(null, Bin, Handler, Stack, Config). + + +comment(<>, Handler, Resume, [comment|Stack], Config) -> + resume(Rest, Resume, Handler, unused, Stack, Config); +comment(<>, Handler, Resume, Stack, Config) -> + comment(Rest, Handler, Resume, [multicomment|Stack], Config); +comment(<>, Handler, Resume, [multicomment|_] = Stack, Config) -> + incomplete(comment, <>, Handler, Resume, Stack, Config); +comment(<>, Handler, Resume, [multicomment|Stack], Config) -> + case Stack of + [multicomment|_] -> comment(Rest, Handler, Resume, Stack, Config); + _ -> resume(Rest, Resume, Handler, unused, Stack, Config) + end; +comment(<>, Handler, Resume, [multicomment|_] = Stack, Config) -> + incomplete(comment, <>, Handler, Resume, Stack, Config); +comment(<<_/utf8, Rest/binary>>, Handler, Resume, Stack, Config) -> + comment(Rest, Handler, Resume, Stack, Config); +comment(<<_, Rest/binary>>, Handler, Resume, Stack, Config=#config{strict_utf8=false}) -> + comment(Rest, Handler, Resume, Stack, Config); +comment(<<>>, Handler, done, [Comment], Config=#config{stream=false}) + when Comment == comment; Comment == multicomment -> + resume(<<>>, done, Handler, unused, [], Config); +comment(<<>>, Handler, Resume, Stack, Config) -> + incomplete(comment, <<>>, Handler, Resume, Stack, Config); +comment(Bin, Handler, Resume, Stack, Config) -> + ?error(comment, Bin, Handler, Resume, Stack, Config). + + +maybe_done(<>, Handler, [], Config) -> + done(Rest, handle_event(end_json, Handler, Config), [], Config); +maybe_done(<>, Handler, Stack, Config) -> + maybe_done(Rest, Handler, Stack, Config); +maybe_done(<>, Handler, [object|Stack], Config) -> + maybe_done(Rest, handle_event(end_object, Handler, Config), Stack, Config); +maybe_done(<>, Handler, [array|Stack], Config) -> + maybe_done(Rest, handle_event(end_array, Handler, Config), Stack, Config); +maybe_done(<>, Handler, [object|Stack], Config) -> + key(Rest, Handler, [key|Stack], Config); +maybe_done(<>, Handler, [array|_] = Stack, Config) -> + value(Rest, Handler, Stack, Config); +maybe_done(<>, Handler, Stack, Config) -> + maybe_done(Rest, Handler, Stack, Config); +maybe_done(<>, Handler, Stack, Config) -> + maybe_done(Rest, Handler, Stack, Config); +maybe_done(<>, Handler, Stack, Config) -> + maybe_done(Rest, Handler, Stack, Config); +maybe_done(<>, Handler, Stack, Config=#config{strict_comments=true}) -> + ?error(maybe_done, <>, Handler, Stack, Config); +maybe_done(<>, Handler, Stack, Config) -> + comment(Rest, Handler, maybe_done, [comment|Stack], Config); +maybe_done(<>, Handler, Stack, Config) -> + comment(Rest, Handler, maybe_done, [multicomment|Stack], Config); +maybe_done(<>, Handler, Stack, Config) -> + incomplete(maybe_done, <>, Handler, Stack, Config); +maybe_done(<<>>, Handler, Stack, Config) when length(Stack) > 0 -> + incomplete(maybe_done, <<>>, Handler, Stack, Config); +maybe_done(Bin, Handler, Stack, Config) -> + ?error(maybe_done, Bin, Handler, Stack, Config). + + +done(<>, Handler, [], Config) -> + done(Rest, Handler, [], Config); +done(<>, Handler, [], Config) -> + done(Rest, Handler, [], Config); +done(<>, Handler, [], Config) -> + done(Rest, Handler, [], Config); +done(<>, Handler, [], Config) -> + done(Rest, Handler, [], Config); +done(<>, Handler, Stack, Config=#config{strict_comments=true}) -> + ?error(done, <>, Handler, Stack, Config); +done(<>, Handler, Stack, Config) -> + comment(Rest, Handler, done, [comment|Stack], Config); +done(<>, Handler, Stack, Config) -> + comment(Rest, Handler, done, [multicomment|Stack], Config); +done(<>, Handler, Stack, Config) -> + incomplete(done, <>, Handler, Stack, Config); +done(Bin, {_Handler, State}, _Stack, #config{return_tail=true}) -> + {with_tail,State, Bin}; +done(<<>>, {Handler, State}, [], Config=#config{stream=true}) -> + incomplete(done, <<>>, {Handler, State}, [], Config); +done(<<>>, {_Handler, State}, [], _Config) -> State; +done(Bin, {Handler, State}, _Stack, Config=#config{multi_term=true}) -> + value(Bin, {Handler, Handler:reset(State)}, [], Config); +done(Bin, Handler, Stack, Config) -> ?error(done, Bin, Handler, Stack, Config). + + + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + + +json_to_bytes(JSON) -> json_to_bytes(JSON, []). + +json_to_bytes(<<>>, Acc) -> [<<>>] ++ lists:reverse(Acc); +json_to_bytes(<>, Acc) -> json_to_bytes(Rest, [<>] ++ Acc). + + +decode(JSON) -> decode(JSON, []). +decode(JSON, Config) -> (decoder(jsx, [], Config))(JSON). + + +incremental_decode(JSON) -> incremental_decode(JSON, []). +incremental_decode(JSON, Config) -> + Final = lists:foldl( + fun(Byte, Decoder) -> {incomplete, F} = Decoder(Byte), F end, + decoder(jsx, [], [stream] ++ Config), + json_to_bytes(JSON) + ), + Final(end_stream). + + +%% all these numbers have different representation in erlang than in javascript and +%% do not roundtrip like most integers/floats +special_number_test_() -> + Cases = [ + % {title, test form, json, opt flags} + {"-0", [{integer, 0}, end_json], <<"-0">>}, + {"-0.0", [{float, 0.0}, end_json], <<"-0.0">>}, + {"0e0", [{float, 0.0}, end_json], <<"0e0">>}, + {"0e4", [{float, 0.0}, end_json], <<"0e4">>}, + {"1e0", [{float, 1.0}, end_json], <<"1e0">>}, + {"-1e0", [{float, -1.0}, end_json], <<"-1e0">>}, + {"-0e0", [{float, -0.0}, end_json], <<"-0e0">>}, + {"1e4", [{float, 1.0e4}, end_json], <<"1e4">>}, + {"number terminated by whitespace", + [start_array, {integer, 1}, end_array, end_json], + <<"[ 1 ]">> + }, + {"number terminated by comma", + [start_array, {integer, 1}, {integer, 1}, end_array, end_json], + <<"[ 1, 1 ]">> + }, + {"number terminated by comma in object", + [start_object, {key, <<"x">>}, {integer, 1}, {key, <<"y">>}, {integer, 1}, end_object, end_json], + <<"{\"x\": 1, \"y\": 1}">> + } + ], + [{Title, ?_assertEqual(Events, decode(JSON))} + || {Title, Events, JSON} <- Cases + ] ++ + [{Title ++ " (incremental)", ?_assertEqual(Events, incremental_decode(JSON))} + || {Title, Events, JSON} <- Cases + ]. + + +comments_test_() -> + Cases = [ + % {title, test form, json, opt flags} + {"preceeding // comment", + [start_array, end_array, end_json], + <<"// comment ", ?newline, "[]">> + }, + {"preceeding /**/ comment", + [start_array, end_array, end_json], + <<"/* comment */[]">> + }, + {"trailing // comment", + [start_array, end_array, end_json], + <<"[]// comment", ?newline>> + }, + {"trailing // comment (no newline)", + [start_array, end_array, end_json], + <<"[]// comment">> + }, + {"trailing /**/ comment", + [start_array, end_array, end_json], + <<"[] /* comment */">> + }, + {"// comment inside array", + [start_array, end_array, end_json], + <<"[ // comment", ?newline, "]">> + }, + {"/**/ comment inside array", + [start_array, end_array, end_json], + <<"[ /* comment */ ]">> + }, + {"// comment at beginning of array", + [start_array, {literal, true}, end_array, end_json], + <<"[ // comment", ?newline, "true", ?newline, "]">> + }, + {"/**/ comment at beginning of array", + [start_array, {literal, true}, end_array, end_json], + <<"[ /* comment */ true ]">> + }, + {"// comment at end of array", + [start_array, {literal, true}, end_array, end_json], + <<"[ true // comment", ?newline, "]">> + }, + {"/**/ comment at end of array", + [start_array, {literal, true}, end_array, end_json], + <<"[ true /* comment */ ]">> + }, + {"// comment midarray (post comma)", + [start_array, {literal, true}, {literal, false}, end_array, end_json], + <<"[ true, // comment", ?newline, "false ]">> + }, + {"/**/ comment midarray (post comma)", + [start_array, {literal, true}, {literal, false}, end_array, end_json], + <<"[ true, /* comment */ false ]">> + }, + {"// comment midarray (pre comma)", + [start_array, {literal, true}, {literal, false}, end_array, end_json], + <<"[ true// comment", ?newline, ", false ]">> + }, + {"/**/ comment midarray (pre comma)", + [start_array, {literal, true}, {literal, false}, end_array, end_json], + <<"[ true/* comment */, false ]">> + }, + {"// comment inside object", + [start_object, end_object, end_json], + <<"{ // comment", ?newline, "}">> + }, + {"/**/ comment inside object", + [start_object, end_object, end_json], + <<"{ /* comment */ }">> + }, + {"// comment at beginning of object", + [start_object, {key, <<"key">>}, {literal, true}, end_object, end_json], + <<"{ // comment", ?newline, " \"key\": true", ?newline, "}">> + }, + {"/**/ comment at beginning of object", + [start_object, {key, <<"key">>}, {literal, true}, end_object, end_json], + <<"{ /* comment */ \"key\": true }">> + }, + {"// comment at end of object", + [start_object, {key, <<"key">>}, {literal, true}, end_object, end_json], + <<"{ \"key\": true // comment", ?newline, "}">> + }, + {"/**/ comment at end of object", + [start_object, {key, <<"key">>}, {literal, true}, end_object, end_json], + <<"{ \"key\": true /* comment */ }">> + }, + {"// comment midobject (post comma)", + [ + start_object, + {key, <<"x">>}, + {literal, true}, + {key, <<"y">>}, + {literal, false}, + end_object, + end_json + ], + <<"{ \"x\": true, // comment", ?newline, "\"y\": false }">> + }, + {"/**/ comment midobject (post comma)", + [ + start_object, + {key, <<"x">>}, + {literal, true}, + {key, <<"y">>}, + {literal, false}, + end_object, + end_json + ], + <<"{ \"x\": true, /* comment */", ?newline, "\"y\": false }">> + }, + {"// comment midobject (pre comma)", + [ + start_object, + {key, <<"x">>}, + {literal, true}, + {key, <<"y">>}, + {literal, false}, + end_object, + end_json + ], + <<"{ \"x\": true// comment", ?newline, ", \"y\": false }">> + }, + {"/**/ comment midobject (pre comma)", + [ + start_object, + {key, <<"x">>}, + {literal, true}, + {key, <<"y">>}, + {literal, false}, + end_object, + end_json + ], + <<"{ \"x\": true/* comment */", ?newline, ", \"y\": false }">> + }, + {"// comment precolon", + [start_object, {key, <<"key">>}, {literal, true}, end_object, end_json], + <<"{ \"key\" // comment", ?newline, ": true }">> + }, + {"/**/ comment precolon", + [start_object, {key, <<"key">>}, {literal, true}, end_object, end_json], + <<"{ \"key\"/* comment */: true }">> + }, + {"// comment postcolon", + [start_object, {key, <<"key">>}, {literal, true}, end_object, end_json], + <<"{ \"key\": // comment", ?newline, " true }">> + }, + {"/**/ comment postcolon", + [start_object, {key, <<"key">>}, {literal, true}, end_object, end_json], + <<"{ \"key\":/* comment */ true }">> + }, + {"// comment terminating zero", + [start_array, {integer, 0}, end_array, end_json], + <<"[ 0// comment", ?newline, "]">> + }, + {"// comment terminating integer", + [start_array, {integer, 1}, end_array, end_json], + <<"[ 1// comment", ?newline, "]">> + }, + {"// comment terminating float", + [start_array, {float, 1.0}, end_array, end_json], + <<"[ 1.0// comment", ?newline, "]">> + }, + {"// comment terminating exp", + [start_array, {float, 1.0e1}, end_array, end_json], + <<"[ 1e1// comment", ?newline, "]">> + }, + {"/**/ comment terminating zero", + [start_array, {integer, 0}, end_array, end_json], + <<"[ 0/* comment */ ]">> + }, + {"/**/ comment terminating integer", + [start_array, {integer, 1}, end_array, end_json], + <<"[ 1/* comment */ ]">> + }, + {"/**/ comment terminating float", + [start_array, {float, 1.0}, end_array, end_json], + <<"[ 1.0/* comment */ ]">> + }, + {"/**/ comment terminating exp", + [start_array, {float, 1.0e1}, end_array, end_json], + <<"[ 1e1/* comment */ ]">> + }, + {"/**/ comment following /**/ comment", + [start_array, {literal, true}, end_array, end_json], + <<"[/* comment *//* comment */true]">> + }, + {"/**/ comment following // comment", + [start_array, {literal, true}, end_array, end_json], + <<"[// comment", ?newline, "/* comment */true]">> + }, + {"// comment following /**/ comment", + [start_array, {literal, true}, end_array, end_json], + <<"[/* comment */// comment", ?newline, "true]">> + }, + {"// comment following // comment", + [start_array, {literal, true}, end_array, end_json], + <<"[// comment", ?newline, "// comment", ?newline, "true]">> + }, + {"/**/ comment inside /**/ comment", + [start_array, {literal, true}, end_array, end_json], + <<"[ /* /* comment */ */ true ]">> + }, + {"/**/ comment with /", + [start_array, {literal, true}, end_array, end_json], + <<"[ /* / */ true ]">> + }, + {"/**/ comment with *", + [start_array, {literal, true}, end_array, end_json], + <<"[ /* * */ true ]">> + }, + {"// comment with badutf", + [start_array, {literal, true}, end_array, end_json], + <<"[ // comment ", 16#00c0, " ", ?newline, "true]">> + }, + {"/**/ comment with badutf", + [start_array, {literal, true}, end_array, end_json], + <<"[ /* comment ", 16#00c0, " */ true]">> + }, + {"/**/ comment with badutf preceeded by /", + [start_array, {literal, true}, end_array, end_json], + <<"[ /* comment /", 16#00c0, " */ true]">> + } + ], + [{Title, ?_assertEqual(Events, decode(JSON))} + || {Title, Events, JSON} <- Cases + ] ++ + [{Title ++ " (incremental)", ?_assertEqual(Events, incremental_decode(JSON))} + || {Title, Events, JSON} <- Cases + ] ++ + % error when `{strict, [comments]}` is present + [{Title, ?_assertError(badarg, decode(JSON, [{strict, [comments]}]))} + || {Title, _Events, JSON} <- Cases + ] ++ + [{Title ++ " (incremental)", ?_assertError( + badarg, + incremental_decode(JSON, [{strict, [comments]}]) + )} || {Title, _Events, JSON} <- Cases + ]. + + +no_comments_test_() -> + Cases = [ + {"// comment with badutf", + badarg, + <<"[ // comment ", 16#00c0, " ", ?newline, "true]">>, + [{strict, [utf8]}] + }, + {"/**/ comment with badutf", + badarg, + <<"[ /* comment ", 16#00c0, " */ true]">>, + [{strict, [utf8]}] + }, + {"/**/ comment with badutf preceeded by /", + badarg, + <<"[ /* comment /", 16#00c0, " */ true]">>, + [{strict, [utf8]}] + } + ], + [{Title, ?_assertError(Error, decode(JSON, Config))} + || {Title, Error, JSON, Config} <- Cases + ] ++ + [{Title ++ " (incremental)", ?_assertError(Error, incremental_decode(JSON, Config))} + || {Title, Error, JSON, Config} <- Cases + ]. + + +% doing the full unicode range takes foreverrrrrrr so just do boundaries +% excludes characters that may need escaping +codepoints() -> + lists:seq(0, 32) ++ + [32, 33] ++ + lists:seq(35, 46) ++ + lists:seq(48, 91) ++ + lists:seq(93, 127) ++ + [16#2027, 16#202a, 16#d7ff, 16#e000] ++ + lists:seq(16#fdd0, 16#ffff) ++ + [16#10000, 16#20000, 16#30000, 16#40000, 16#50000] ++ + [16#60000, 16#70000, 16#80000, 16#90000, 16#a0000, 16#b0000] ++ + [16#c0000, 16#d0000, 16#e0000, 16#f0000, 16#100000]. + + +surrogates() -> lists:seq(16#d800, 16#dfff). + + +%% erlang refuses to decode certain codepoints, so fake them all +to_fake_utf8(N) when N < 16#0080 -> <<34/utf8, N:8, 34/utf8>>; +to_fake_utf8(N) when N < 16#0800 -> + <<0:5, Y:5, X:6>> = <>, + <<34/utf8, 2#110:3, Y:5, 2#10:2, X:6, 34/utf8>>; +to_fake_utf8(N) when N < 16#10000 -> + <> = <>, + <<34/utf8, 2#1110:4, Z:4, 2#10:2, Y:6, 2#10:2, X:6, 34/utf8>>; +to_fake_utf8(N) -> + <<0:3, W:3, Z:6, Y:6, X:6>> = <>, + <<34/utf8, 2#11110:5, W:3, 2#10:2, Z:6, 2#10:2, Y:6, 2#10:2, X:6, 34/utf8>>. + + +clean_string_test_() -> + Clean = codepoints(), + Dirty = surrogates(), + % clean codepoints + [{"clean u+" ++ integer_to_list(Codepoint, 16), ?_assertEqual( + [{string, <>}, end_json], + decode(<<34/utf8, Codepoint/utf8, 34/utf8>>) + )} || Codepoint <- Clean + ] ++ + % bad codepoints replaced by u+FFFD + [{"clean u+" ++ integer_to_list(Codepoint, 16), ?_assertEqual( + [{string, <<16#fffd/utf8>>}, end_json], + decode(to_fake_utf8(Codepoint)) + )} || Codepoint <- Dirty + ] ++ + % bad codepoints that cause errors + [{"dirty u+" ++ integer_to_list(Codepoint, 16), ?_assertError( + badarg, + decode(to_fake_utf8(Codepoint), [{strict, [utf8]}]) + )} || Codepoint <- Dirty + ]. + + +dirty_string_test_() -> + Cases = [ + {"dirty \\n", + [start_array, {string, <<"\\n">>}, end_array, end_json], + <<"[\"\\n\"]">>, + [dirty_strings] + }, + {"dirty \\uwxyz", + [start_array, {string, <<"\\uwxyz">>}, end_array, end_json], + <<"[\"\\uwxyz\"]">>, + [dirty_strings] + }, + {"dirty \\x23", + [start_array, {string, <<"\\x23">>}, end_array, end_json], + <<"[\"\\x23\"]">>, + [dirty_strings] + }, + {"dirty 0", + [start_array, {string, <<0>>}, end_array, end_json], + <<"[\"", 0, "\"]">>, + [dirty_strings] + }, + {"dirty 0\\\"0", + [start_array, {string, <<0, ?rsolidus, ?doublequote, 0>>}, end_array, end_json], + <<"[\"", 0, ?rsolidus, ?doublequote, 0, "\"]">>, + [dirty_strings] + }, + {"dirty 0\\\\\"0", + [start_array, {string, <<0, ?rsolidus, ?rsolidus, ?doublequote, 0>>}, end_array, end_json], + <<"[\"", 0, ?rsolidus, ?rsolidus, ?doublequote, 0, "\"]">>, + [dirty_strings] + }, + {"dirty 16#d800", + [start_array, {string, <<237, 160, 128>>}, end_array, end_json], + <<"[\"", 237, 160, 128, "\"]">>, + [dirty_strings] + }, + {"dirty /", + [start_array, {string, <<$/>>}, end_array, end_json], + <<"[\"", $/, "\"]">>, + [dirty_strings, escaped_forward_slashes] + }, + {"dirty <<194, 129>>", + [start_array, {string, <<194, 129>>}, end_array, end_json], + <<"[\"", 194, 129, "\"]">>, + [dirty_strings] + } + ], + [{Title, ?_assertEqual(Events, decode(JSON, Config))} + || {Title, Events, JSON, Config} <- Cases + ] ++ + % ensure `dirty_strings` and `strict` interact properly + [{Title, ?_assertEqual(Events, decode(JSON, Config ++ [strict]))} + || {Title, Events, JSON, Config} <- Cases + ] ++ + [{Title ++ " (incremental)", ?_assertEqual(Events, incremental_decode(JSON, Config))} + || {Title, Events, JSON, Config} <- Cases + ]. + + +bad_utf8_test_() -> + Cases = [ + {"orphan continuation byte u+0080", <<16#fffd/utf8>>, <<16#0080>>}, + {"orphan continuation byte u+00bf", <<16#fffd/utf8>>, <<16#00bf>>}, + {"2 continuation bytes", + binary:copy(<<16#fffd/utf8>>, 2), + <<(binary:copy(<<16#0080>>, 2))/binary>> + }, + {"3 continuation bytes", + binary:copy(<<16#fffd/utf8>>, 3), + <<(binary:copy(<<16#0080>>, 3))/binary>> + }, + {"4 continuation bytes", + binary:copy(<<16#fffd/utf8>>, 4), + <<(binary:copy(<<16#0080>>, 4))/binary>> + }, + {"5 continuation bytes", + binary:copy(<<16#fffd/utf8>>, 5), + <<(binary:copy(<<16#0080>>, 5))/binary>> + }, + {"6 continuation bytes", + binary:copy(<<16#fffd/utf8>>, 6), + <<(binary:copy(<<16#0080>>, 6))/binary>> + }, + {"all continuation bytes", + binary:copy(<<16#fffd/utf8>>, length(lists:seq(16#0080, 16#00bf))), + <<(list_to_binary(lists:seq(16#0080, 16#00bf)))/binary>> + }, + {"lonely start byte", <<16#fffd/utf8>>, <<16#00c0>>}, + {"lonely start bytes (2 byte)", + <<16#fffd/utf8, 32, 16#fffd/utf8>>, + <<16#00c0, 32, 16#00df>> + }, + {"lonely start bytes (3 byte)", + <<16#fffd/utf8, 32, 16#fffd/utf8>>, + <<16#00e0, 32, 16#00ef>> + }, + {"lonely start bytes (4 byte)", + <<16#fffd/utf8, 32, 16#fffd/utf8>>, + <<16#00f0, 32, 16#00f7>> + }, + {"missing continuation byte (3 byte)", <<16#fffd/utf8, 32>>, <<224, 160, 32>>}, + {"missing continuation byte (4 byte missing one)", + <<16#fffd/utf8, 32>>, + <<240, 144, 128, 32>> + }, + {"missing continuation byte (4 byte missing two)", + <<16#fffd/utf8, 32>>, + <<240, 144, 32>> + }, + {"overlong encoding of u+002f (2 byte)", + <<16#fffd/utf8, 32>>, + <<16#c0, 16#af, 32>> + }, + {"overlong encoding of u+002f (3 byte)", + <<16#fffd/utf8, 32>>, + <<16#e0, 16#80, 16#af, 32>> + }, + {"overlong encoding of u+002f (4 byte)", + <<16#fffd/utf8, 32>>, + <<16#f0, 16#80, 16#80, 16#af, 32>> + }, + {"highest overlong 2 byte sequence", + <<16#fffd/utf8, 32>>, + <<16#c1, 16#bf, 32>> + }, + {"highest overlong 3 byte sequence", + <<16#fffd/utf8, 32>>, + <<16#e0, 16#9f, 16#bf, 32>> + }, + {"highest overlong 4 byte sequence", + <<16#fffd/utf8, 32>>, + <<16#f0, 16#8f, 16#bf, 16#bf, 32>> + } + ], + [{Title, ?_assertError( + badarg, + decode(<<34, JSON/binary, 34>>, [{strict, [utf8]}]) + )} || {Title, _, JSON} <- Cases + ] ++ + [{Title ++ " (incremental)", ?_assertError( + badarg, + incremental_decode(<<34, JSON/binary, 34>>, [{strict, [utf8]}]) + )} || {Title, _, JSON} <- Cases + ] ++ + [{Title ++ " replaced", ?_assertEqual( + [{string, Replacement}, end_json], + decode(<<34, JSON/binary, 34>>) + )} || {Title, Replacement, JSON} <- Cases + ] ++ + [{Title ++ " replaced (incremental)", ?_assertEqual( + [{string, Replacement}, end_json], + incremental_decode(<<34, JSON/binary, 34>>) + )} || {Title, Replacement, JSON} <- Cases + ]. + + +unescape_test_() -> + Cases = [ + {"unescape backspace", <<"\b">>, <<"\\b"/utf8>>}, + {"unescape tab", <<"\t">>, <<"\\t"/utf8>>}, + {"unescape newline", <<"\n">>, <<"\\n"/utf8>>}, + {"unescape formfeed", <<"\f">>, <<"\\f"/utf8>>}, + {"unescape carriage return", <<"\r">>, <<"\\r"/utf8>>}, + {"unescape quote", <<"\"">>, <<"\\\""/utf8>>}, + {"unescape solidus", <<"/">>, <<"\\/"/utf8>>}, + {"unescape reverse solidus", <<"\\">>, <<"\\\\"/utf8>>}, + {"unescape control", <<0>>, <<"\\u0000"/utf8>>}, + {"unescape surrogate pair", <<16#10000/utf8>>, <<"\\ud800\\udc00"/utf8>>}, + {"unescape surrogate pair", <<16#10000/utf8>>, <<"\\uD800\\uDC00"/utf8>>}, + {"replace bad high surrogate", <<16#fffd/utf8>>, <<"\\udc00"/utf8>>}, + {"replace bad high surrogate", <<16#fffd/utf8>>, <<"\\uDC00"/utf8>>}, + {"replace naked high surrogate", + <<16#fffd/utf8, "hello world">>, + <<"\\ud800hello world"/utf8>> + }, + {"replace naked high surrogate", + <<16#fffd/utf8, "hello world">>, + <<"\\uD800hello world"/utf8>> + }, + {"replace naked low surrogate", + <<16#fffd/utf8, "hello world">>, + <<"\\udc00hello world"/utf8>> + }, + {"replace naked low surrogate", + <<16#fffd/utf8, "hello world">>, + <<"\\uDC00hello world"/utf8>> + }, + {"replace bad surrogate pair", <<16#fffd/utf8, 16#fffd/utf8>>, <<"\\ud800\\u0000">>}, + {"replace bad surrogate pair", <<16#fffd/utf8, 16#fffd/utf8>>, <<"\\uD800\\u0000">>} + ], + [{Title, ?_assertEqual([{string, Escaped}, end_json], decode(<<34, JSON/binary, 34>>))} + || {Title, Escaped, JSON} <- Cases + ] ++ + [{Title ++ " (incremental)", ?_assertEqual( + [{string, Escaped}, end_json], + incremental_decode(<<34, JSON/binary, 34>>) + )} || {Title, Escaped, JSON} <- Cases + ]. + + +bad_escaped_surrogate_test_() -> + Cases = [ + {"do not unescape bad high surrogate", <<"\\udc00">>}, + {"do not unescape naked high surrogate", <<"\\ud800hello world">>}, + {"do not unescape naked low surrogate", <<"\\udc00hello world">>}, + {"do not unescape bad surrogate pair", <<"\\ud800\\u0000">>} + ], + [{Title, ?_assertError(badarg, decode(<<34, JSON/binary, 34>>, [{strict, [utf8]}]))} + || {Title, JSON} <- Cases + ]. + + +escape_test_() -> + Cases = [ + {"backspace", <<"\b">>, <<"\\b">>}, + {"tab", <<"\t">>, <<"\\t">>}, + {"newline", <<"\n">>, <<"\\n">>}, + {"formfeed", <<"\f">>, <<"\\f">>}, + {"carriage return", <<"\r">>, <<"\\r">>}, + {"quote", <<"\"">>, <<"\\\"">>}, + {"backslash", <<"\\">>, <<"\\\\">>}, + {"control", <<0>>, <<"\\u0000">>} + ], + [{"escape " ++ Title, ?_assertEqual( + [{string, Escaped}, end_json], + decode(<<34, Escaped/binary, 34>>, [escaped_strings]) + )} || {Title, _Unescaped, Escaped} <- Cases + ] ++ + [{"do not escape " ++ Title, ?_assertEqual( + [{string, Unescaped}, end_json], + decode(<<34, Escaped/binary, 34>>) + )} || {Title, Unescaped, Escaped} <- Cases + ]. + + +special_escape_test_() -> + Cases = [ + {"escape forward slash", <<"\\/">>, <<"/"/utf8>>, [escaped_forward_slashes]}, + {"do not escape forward slash", <<"/">>, <<"/"/utf8>>, []}, + {"escape jsonp", <<"\\u2028">>, <<16#2028/utf8>>, []}, + {"do not escape jsonp", <<16#2028/utf8>>, <<16#2028/utf8>>, [unescaped_jsonp]} + ], + [{Title, ?_assertEqual( + [{string, Expect}, end_json], + decode(<<34, Raw/binary, 34>>, [escaped_strings] ++ Config) + )} || {Title, Expect, Raw, Config} <- Cases + ]. + + +uescape_test_() -> + [ + {"\"\\u0080\"", ?_assertEqual( + [{string, <<"\\u0080">>}, end_json], + decode(<<34, 128/utf8, 34>>, [uescape]) + )}, + {"\"\\u8ca8\\u5481\\u3002\\u0091\\u0091\"", ?_assertEqual( + [{string, <<"\\u8ca8\\u5481\\u3002\\u0091\\u0091">>}, end_json], + decode( + <<34,232,178,168,229,146,129,227,128,130,194,145,194,145,34>>, + [uescape] + ) + )}, + {"\"\\ud834\\udd1e\"", ?_assertEqual( + [{string, <<"\\ud834\\udd1e">>}, end_json], + decode(<<34, 240, 157, 132, 158, 34>>, [uescape]) + )}, + {"\"\\ud83d\\ude0a\"", ?_assertEqual( + [{string, <<"\\ud83d\\ude0a">>}, end_json], + decode(<<34, 240, 159, 152, 138, 34>>, [uescape]) + )} + ]. + + +single_quoted_string_test_() -> + Cases = [ + {"single quoted string", [{string, <<"hello world">>}, end_json], <<39, "hello world", 39>>}, + {"single quoted string with embedded double quotes", + [{string, <<"quoth the raven, \"nevermore\"">>}, end_json], + <<39, "quoth the raven, \"nevermore\"", 39>> + }, + {"escaped single quote", + [{string, <<"quoth the raven, 'nevermore'">>}, end_json], + <<39, "quoth the raven, \\'nevermore\\'", 39>> + }, + {"single quoted key", + [start_object, + {key, <<"key">>}, {string, <<"value">>}, + {key, <<"another key">>}, {string, <<"another value">>}, + end_object, end_json], + <<"{'key':'value','another key':'another value'}">> + } + ], + [{Title, ?_assertEqual(Expect, decode(Raw, []))} || {Title, Expect, Raw} <- Cases] ++ + [{Title, ?_assertError( + badarg, + decode(Raw, [{strict, [single_quotes]}]) + )} || {Title, _Expect, Raw} <- Cases + ]. + + +embedded_single_quoted_string_test_() -> + [ + {"string with embedded single quotes", ?_assertEqual( + [{string, <<"quoth the raven, 'nevermore'">>}, end_json], + decode(<<34, "quoth the raven, 'nevermore'", 34>>, []) + )}, + {"string with embedded single quotes", ?_assertEqual( + [{string, <<"quoth the raven, 'nevermore'">>}, end_json], + decode(<<34, "quoth the raven, 'nevermore'", 34>>, [{strict, [single_quotes]}]) + )} + ]. + + +ignored_bad_escapes_test_() -> + [ + {"ignore unrecognized escape sequence", ?_assertEqual( + [{string, <<"\\x25">>}, end_json], + decode(<<"\"\\x25\"">>, []) + )} + ]. + + +bom_test_() -> + [ + {"bom", ?_assertEqual( + [start_array, end_array, end_json], + decode(<<16#ef, 16#bb, 16#bf, "[]"/utf8>>, []) + )} + ]. + + +trailing_comma_test_() -> + [ + {"trailing comma in object", ?_assertEqual( + [start_object, {key, <<"key">>}, {literal, true}, end_object, end_json], + decode(<<"{\"key\": true,}">>, []) + )}, + {"strict trailing comma in object", ?_assertError( + badarg, + decode(<<"{\"key\": true,}">>, [{strict, [trailing_commas]}]) + )}, + {"two trailing commas in object", ?_assertError( + badarg, + decode(<<"{\"key\": true,,}">>, []) + )}, + {"comma in empty object", ?_assertError( + badarg, + decode(<<"{,}">>, []) + )}, + {"trailing comma in list", ?_assertEqual( + [start_array, {literal, true}, end_array, end_json], + decode(<<"[true,]">>, []) + )}, + {"strict trailing comma in list", ?_assertError( + badarg, + decode(<<"[true,]">>, [{strict, [trailing_commas]}]) + )}, + {"two trailing commas in list", ?_assertError( + badarg, + decode(<<"[true,,]">>, []) + )}, + {"comma in empty list", ?_assertError( + badarg, + decode(<<"[,]">>, []) + )} + ]. + + +incomplete_test_() -> + [ + {"stream false", ?_assertError( + badarg, + decode(<<"{">>) + )}, + {"stream true", ?_assertMatch( + {incomplete, _}, + decode(<<"{">>, [stream]) + )}, + {"complete input", ?_assertMatch( + {incomplete, _}, + decode(<<"{}">>, [stream]) + )} + ]. + + +error_test_() -> + Cases = [ + {"maybe_bom error", <<16#ef, 0>>}, + {"definitely_bom error", <<16#ef, 16#bb, 0>>}, + {"object error", <<"{"/utf8, 0>>}, + {"colon error", <<"{\"\""/utf8, 0>>}, + {"key error", <<"{\"\":1,"/utf8, 0>>}, + {"value error", <<0>>}, + {"negative error", <<"-"/utf8, 0>>}, + {"zero error", <<"0"/utf8, 0>>}, + {"integer error", <<"1"/utf8, 0>>}, + {"decimal error", <<"1.0"/utf8, 0>>}, + {"e error", <<"1e"/utf8, 0>>}, + {"ex error", <<"1e+"/utf8, 0>>}, + {"exp error", <<"1e1"/utf8, 0>>}, + {"exp error", <<"1.0e1"/utf8, 0>>}, + {"exp error", <<"1.e"/utf8>>}, + {"true error", <<"tru"/utf8, 0>>}, + {"false error", <<"fals"/utf8, 0>>}, + {"null error", <<"nul"/utf8, 0>>}, + {"maybe_done error", <<"[[]"/utf8, 0>>}, + {"done error", <<"[]"/utf8, 0>>} + ], + [{Title, ?_assertError(badarg, decode(State))} || {Title, State} <- Cases]. + + +custom_incomplete_handler_test_() -> + [ + {"custom incomplete handler", ?_assertError( + incomplete, + decode(<<>>, [{incomplete_handler, fun(_, _, _) -> erlang:error(incomplete) end}, stream]) + )} + ]. + + +return_tail_test_() -> + [ + {"return_tail with tail", ?_assertEqual( + {with_tail,[{}],<<"3">>}, + jsx:decode(<<"{} 3">>, [return_tail]) + )}, + {"return_tail without tail", ?_assertEqual( + {with_tail,[{}],<<"">>}, + jsx:decode(<<"{}">>, [return_tail]) + )}, + {"return_tail with trimmed whitespace", ?_assertEqual( + {with_tail,[{}],<<"">>}, + jsx:decode(<<"{} ">>, [return_tail]) + )}, + {"return_tail and streaming", ?_assertEqual( + {with_tail,[{}],<<"3">>}, + begin + {incomplete, F} = jsx:decode(<<"{">>, [return_tail, stream]), + F(<<"} 3">>) + end + )}, + {"return_tail and streaming", ?_assertEqual( + {with_tail,[{}],<<"">>}, + begin + %% In case of infinite stream of objects a user does not know + %% when to call F(end_stream). + %% So, return_tail overwrites conservative stream end. + %% This means that we don't need to call end_stream explicitly. + {incomplete, F} = jsx:decode(<<"{">>, [return_tail, stream]), + F(<<"}">>) + end + )} + ]. + +-endif. diff --git a/test/data/jsx/jsx_encoder.core b/test/data/jsx/jsx_encoder.core new file mode 100644 index 0000000..fff85c3 --- /dev/null +++ b/test/data/jsx/jsx_encoder.core @@ -0,0 +1,184 @@ +module 'jsx_encoder' ['encode'/1, + 'encode'/2, + 'encoder'/3, + 'module_info'/0, + 'module_info'/1] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[101|[110|[99|[111|[100|[101|[114|[46|[101|[114|[108]]]]]]]]]]]]]]],1}], + %% Line 28 + 'spec' = + %% Line 28 + [{{'encoder',3},[{'type',28,'fun',[{'type',28,'product',[{'ann_type',28,[{'var',28,'Handler'}|[{'type',28,'module',[]}]]}|[{'ann_type',28,[{'var',28,'State'}|[{'type',28,'any',[]}]]}|[{'ann_type',28,[{'var',28,'Config'}|[{'type',28,'list',[]}]]}]]]}|[{'remote_type',28,[{'atom',28,'jsx'}|[{'atom',28,'encoder'}|[[]]]]}]]}]}], + %% Line 35 + 'spec' = + %% Line 35 + [{{'encode',1},[{'type',35,'fun',[{'type',35,'product',[{'ann_type',35,[{'var',35,'Term'}|[{'type',35,'any',[]}]]}]}|[{'type',35,'any',[]}]]}]}], + %% Line 40 + 'spec' = + %% Line 40 + [{{'encode',2},[{'type',40,'fun',[{'type',40,'product',[{'ann_type',40,[{'var',40,'Term'}|[{'type',40,'any',[]}]]}|[{'ann_type',40,[{'var',40,'EntryPoint'}|[{'type',40,'module',[]}]]}]]}|[{'type',40,'any',[]}]]}]}]] +'encoder'/3 = + %% Line 30 + fun (_0,_1,_2) -> + let = + call %% Line 31 + 'jsx':%% Line 31 + 'parser' + (_0, _1, _2) + in %% Line 32 + ( fun (_6) -> + let <_4> = + apply 'encode'/1 + (_6) + in let <_5> = + call 'erlang':'++' + (_4, ['end_json']) + in apply Parser + (_5) + -| [{'id',{0,0,'-encoder/3-fun-0-'}}] ) +'encode'/1 = + %% Line 37 + fun (_0) -> + apply 'encode'/2 + (_0, 'jsx_encoder') +'encode'/2 = + %% Line 43 + fun (_0,_1) -> + apply 'encode_'/2 + (_0, _1) +'encode_'/2 = + %% Line 54 + fun (_0,_1) -> + case <_0,_1> of + <[],_X_EntryPoint> when 'true' -> + ['start_array'|['end_array']] + %% Line 55 + <[{}],_X_EntryPoint> when 'true' -> + ['start_object'|['end_object']] + %% Line 58 + <[DateTime = {{_8,_9,_10},{_11,_12,_13}}|Rest],EntryPoint> when 'true' -> + let <_2> = + apply %% Line 59 + 'unhitch'/2 + (%% Line 59 + Rest, %% Line 59 + EntryPoint) + in let <_3> = + [%% Line 59 + DateTime|_2] + in %% Line 59 + ['start_array'|_3] + %% Line 60 + when 'true' -> + let <_4> = + apply %% Line 61 + 'unzip'/2 + (%% Line 61 + Term, %% Line 61 + EntryPoint) + in %% Line 61 + ['start_object'|_4] + %% Line 62 + + when call 'erlang':'is_list' + (Term) -> + let <_5> = + apply %% Line 63 + 'unhitch'/2 + (%% Line 63 + Term, %% Line 63 + EntryPoint) + in %% Line 63 + ['start_array'|_5] + %% Line 65 + when 'true' -> + [Else|[]] + end +'unzip'/2 = + %% Line 68 + fun (_0,_1) -> + case <_0,_1> of + <[{K,V}|Rest],EntryPoint> + when let <_2> = + call 'erlang':'is_integer' + (K) + in let <_3> = + call 'erlang':'is_binary' + (K) + in let <_4> = + call 'erlang':'is_atom' + (K) + in let <_5> = + call 'erlang':'or' + (_3, _4) + in call 'erlang':'or' + (_2, _5) -> + let <_7> = + call %% Line 69 + EntryPoint:%% Line 69 + 'encode' + (%% Line 69 + V, %% Line 69 + EntryPoint) + in let <_6> = + apply %% Line 69 + 'unzip'/2 + (%% Line 69 + Rest, %% Line 69 + EntryPoint) + in let <_8> = + call %% Line 69 + 'erlang':%% Line 69 + '++' + (_7, _6) + in %% Line 69 + [K|_8] + %% Line 70 + <[],_11> when 'true' -> + ['end_object'] + %% Line 71 + <_12,_13> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'unhitch'/2 = + %% Line 74 + fun (_0,_1) -> + case <_0,_1> of + <[V|Rest],EntryPoint> when 'true' -> + let <_3> = + call %% Line 75 + EntryPoint:%% Line 75 + 'encode' + (%% Line 75 + V, %% Line 75 + EntryPoint) + in let <_2> = + apply %% Line 75 + 'unhitch'/2 + (%% Line 75 + Rest, %% Line 75 + EntryPoint) + in %% Line 75 + call 'erlang':'++' + (_3, _2) + %% Line 76 + <[],_6> when 'true' -> + ['end_array'] + ( <_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4}) + -| [{'function_name',{'unhitch',2}}] ) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('jsx_encoder') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('jsx_encoder', _0) +end \ No newline at end of file diff --git a/test/data/jsx/jsx_encoder.erl b/test/data/jsx/jsx_encoder.erl new file mode 100644 index 0000000..39140d8 --- /dev/null +++ b/test/data/jsx/jsx_encoder.erl @@ -0,0 +1,127 @@ +%% The MIT License + +%% Copyright (c) 2010-2013 Alisdair Sullivan + +%% Permission is hereby granted, free of charge, to any person obtaining a copy +%% of this software and associated documentation files (the "Software"), to deal +%% in the Software without restriction, including without limitation the rights +%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%% copies of the Software, and to permit persons to whom the Software is +%% furnished to do so, subject to the following conditions: + +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. + +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +%% THE SOFTWARE. + + +-module(jsx_encoder). + +-export([encoder/3, encode/1, encode/2]). + +-spec encoder(Handler::module(), State::any(), Config::list()) -> jsx:encoder(). + +encoder(Handler, State, Config) -> + Parser = jsx:parser(Handler, State, Config), + fun(Term) -> Parser(encode(Term) ++ [end_json]) end. + + +-spec encode(Term::any()) -> any(). + +encode(Term) -> encode(Term, ?MODULE). + + +-spec encode(Term::any(), EntryPoint::module()) -> any(). + +-ifndef(maps_support). +encode(Term, EntryPoint) -> encode_(Term, EntryPoint). +-endif. + +-ifdef(maps_support). +encode(Map, _EntryPoint) when is_map(Map), map_size(Map) < 1 -> + [start_object, end_object]; +encode(Term, EntryPoint) when is_map(Term) -> + [start_object] ++ unpack(Term, EntryPoint); +encode(Term, EntryPoint) -> encode_(Term, EntryPoint). +-endif. + +encode_([], _EntryPoint) -> [start_array, end_array]; +encode_([{}], _EntryPoint) -> [start_object, end_object]; + +%% datetime special case +encode_([{{_,_,_},{_,_,_}} = DateTime|Rest], EntryPoint) -> + [start_array] ++ [DateTime] ++ unhitch(Rest, EntryPoint); +encode_([{_, _}|_] = Term, EntryPoint) -> + [start_object] ++ unzip(Term, EntryPoint); +encode_(Term, EntryPoint) when is_list(Term) -> + [start_array] ++ unhitch(Term, EntryPoint); + +encode_(Else, _EntryPoint) -> [Else]. + + +unzip([{K, V}|Rest], EntryPoint) when is_integer(K); is_binary(K); is_atom(K) -> + [K] ++ EntryPoint:encode(V, EntryPoint) ++ unzip(Rest, EntryPoint); +unzip([], _) -> [end_object]; +unzip(_, _) -> erlang:error(badarg). + + +unhitch([V|Rest], EntryPoint) -> + EntryPoint:encode(V, EntryPoint) ++ unhitch(Rest, EntryPoint); +unhitch([], _) -> [end_array]. + + +-ifdef(maps_support). +unpack(Map, EntryPoint) -> unpack(Map, maps:keys(Map), EntryPoint). + +unpack(Map, [K|Rest], EntryPoint) when is_integer(K); is_binary(K); is_atom(K) -> + [K] ++ EntryPoint:encode(maps:get(K, Map), EntryPoint) ++ unpack(Map, Rest, EntryPoint); +unpack(_, [], _) -> [end_object]. +-endif. + + + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + + +parser(Term, Opts) -> (jsx:parser(jsx, [], Opts))(Term). + + +error_test_() -> + [ + {"value error", ?_assertError(badarg, parser(self(), []))}, + {"string error", ?_assertError(badarg, parser(<<239, 191, 191>>, [strict]))} + ]. + +custom_error_handler_test_() -> + Error = fun(Term, {_, State, _, _}, _) -> {State, Term} end, + [ + {"value error", ?_assertEqual( + {value, [self()]}, + parser(self(), [{error_handler, Error}]) + )}, + {"string error", ?_assertEqual( + {value, [{string, <<237, 160, 128>>}]}, + parser(<<237, 160, 128>>, [{error_handler, Error}, strict]) + )} + ]. + +improper_lists_test_() -> + [ + {"improper proplist", ?_assertError( + badarg, + encode([{<<"key">>, <<"value">>}, false]) + )}, + {"improper list", ?_assertError( + badarg, + encode([{literal, true}, false, null]) + )} + ]. + +-endif. diff --git a/test/data/jsx/jsx_parser.core b/test/data/jsx/jsx_parser.core new file mode 100644 index 0000000..e582254 --- /dev/null +++ b/test/data/jsx/jsx_parser.core @@ -0,0 +1,3366 @@ +module 'jsx_parser' ['handle_event'/2, + 'init'/1, + 'module_info'/0, + 'module_info'/1, + 'parser'/3, + 'resume'/5] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[112|[97|[114|[115|[101|[114|[46|[101|[114|[108]]]]]]]]]]]]]],1}], + %% Line 30 + 'spec' = + %% Line 30 + [{{'parser',3},[{'type',30,'fun',[{'type',30,'product',[{'ann_type',30,[{'var',30,'Handler'}|[{'type',30,'module',[]}]]}|[{'ann_type',30,[{'var',30,'State'}|[{'type',30,'any',[]}]]}|[{'ann_type',30,[{'var',30,'Config'}|[{'type',30,'list',[]}]]}]]]}|[{'remote_type',30,[{'atom',30,'jsx'}|[{'atom',30,'parser'}|[[]]]]}]]}]}], + %% Line 38 + 'spec' = + %% Line 38 + [{{'resume',5},[{'type',38,'fun',[{'type',38,'product',[{'ann_type',39,[{'var',39,'Rest'}|[{'remote_type',39,[{'atom',39,'jsx'}|[{'atom',39,'token'}|[[]]]]}]]}|[{'ann_type',40,[{'var',40,'State'}|[{'type',40,'atom',[]}]]}|[{'ann_type',41,[{'var',41,'Handler'}|[{'type',41,'module',[]}]]}|[{'ann_type',42,[{'var',42,'Stack'}|[{'type',42,'list',[{'type',42,'atom',[]}]}]]}|[{'ann_type',43,[{'var',43,'Config'}|[{'remote_type',43,[{'atom',43,'jsx'}|[{'atom',43,'config'}|[[]]]]}]]}]]]]]}|[{'type',44,'union',[{'remote_type',44,[{'atom',44,'jsx'}|[{'atom',44,'parser'}|[[]]]]}|[{'type',44,'tuple',[{'atom',44,'incomplete'}|[{'remote_type',44,[{'atom',44,'jsx'}|[{'atom',44,'parser'}|[[]]]]}]]}]]}]]}]}], + %% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[99|[111|[110|[102|[105|[103|[46|[104|[114|[108]]]]]]]]]]]]]],1}], + %% Line 1 + 'record' = + %% Line 1 + [{'config',[{'typed_record_field',{'record_field',2,{'atom',2,'dirty_strings'},{'atom',2,'false'}},{'type',2,'boolean',[]}}|[{'typed_record_field',{'record_field',3,{'atom',3,'escaped_forward_slashes'},{'atom',3,'false'}},{'type',3,'boolean',[]}}|[{'typed_record_field',{'record_field',4,{'atom',4,'escaped_strings'},{'atom',4,'false'}},{'type',4,'boolean',[]}}|[{'typed_record_field',{'record_field',5,{'atom',5,'multi_term'},{'atom',5,'false'}},{'type',5,'boolean',[]}}|[{'typed_record_field',{'record_field',6,{'atom',6,'strict_comments'},{'atom',6,'false'}},{'type',6,'boolean',[]}}|[{'typed_record_field',{'record_field',7,{'atom',7,'strict_commas'},{'atom',7,'false'}},{'type',7,'boolean',[]}}|[{'typed_record_field',{'record_field',8,{'atom',8,'strict_utf8'},{'atom',8,'false'}},{'type',8,'boolean',[]}}|[{'typed_record_field',{'record_field',9,{'atom',9,'strict_single_quotes'},{'atom',9,'false'}},{'type',9,'boolean',[]}}|[{'typed_record_field',{'record_field',10,{'atom',10,'strict_escapes'},{'atom',10,'false'}},{'type',10,'boolean',[]}}|[{'typed_record_field',{'record_field',11,{'atom',11,'strict_control_codes'},{'atom',11,'false'}},{'type',11,'boolean',[]}}|[{'typed_record_field',{'record_field',12,{'atom',12,'stream'},{'atom',12,'false'}},{'type',12,'boolean',[]}}|[{'typed_record_field',{'record_field',13,{'atom',13,'return_tail'},{'atom',13,'false'}},{'type',13,'boolean',[]}}|[{'typed_record_field',{'record_field',14,{'atom',14,'uescape'},{'atom',14,'false'}},{'type',14,'boolean',[]}}|[{'typed_record_field',{'record_field',15,{'atom',15,'unescaped_jsonp'},{'atom',15,'false'}},{'type',15,'boolean',[]}}|[{'typed_record_field',{'record_field',16,{'atom',16,'error_handler'},{'atom',16,'false'}},{'type',16,'union',[{'atom',16,'false'}|[{'remote_type',16,[{'atom',16,'jsx_config'}|[{'atom',16,'handler'}|[[]]]]}]]}}|[{'typed_record_field',{'record_field',17,{'atom',17,'incomplete_handler'},{'atom',17,'false'}},{'type',17,'union',[{'atom',17,'false'}|[{'remote_type',17,[{'atom',17,'jsx_config'}|[{'atom',17,'handler'}|[[]]]]}]]}}]]]]]]]]]]]]]]]]}], + %% Line 57 + 'file' = + %% Line 57 + [{[106|[115|[120|[95|[112|[97|[114|[115|[101|[114|[46|[101|[114|[108]]]]]]]]]]]]]],57}], + %% Line 633 + 'spec' = + %% Line 633 + [{{'init',1},[{'type',633,'fun',[{'type',633,'product',[{'remote_type',633,[{'atom',633,'proplists'}|[{'atom',633,'proplist'}|[[]]]]}]}|[{'type',633,'list',[]}]]}]}], + %% Line 638 + 'spec' = + %% Line 638 + [{{'handle_event',2},[{'type',638,'fun',[{'type',638,'product',[{'ann_type',638,[{'var',638,'Event'}|[{'type',638,'any',[]}]]}|[{'ann_type',638,[{'var',638,'Acc'}|[{'type',638,'list',[]}]]}]]}|[{'type',638,'list',[]}]]}]}]] +'parser'/3 = + %% Line 32 + fun (_0,_1,_2) -> + %% Line 33 + ( fun (_5) -> + let <_4> = + call _0:'init' + (_1) + in let <_3> = + call 'jsx_config':'parse_config' + (_2) + in apply 'value'/4 + (_5, {_0,_4}, [], _3) + -| [{'id',{0,0,'-parser/3-fun-0-'}}] ) +'resume'/5 = + %% Line 46 + fun (_0,_1,_2,_3,_4) -> + %% Line 47 + case _1 of + %% Line 48 + <'value'> when 'true' -> + apply 'value'/4 + (_0, _2, _3, _4) + %% Line 49 + <'object'> when 'true' -> + apply 'object'/4 + (_0, _2, _3, _4) + %% Line 50 + <'array'> when 'true' -> + apply 'array'/4 + (_0, _2, _3, _4) + %% Line 51 + <'maybe_done'> when 'true' -> + apply 'maybe_done'/4 + (_0, _2, _3, _4) + %% Line 52 + <'done'> when 'true' -> + apply 'done'/4 + (_0, _2, _3, _4) + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end +'incomplete'/4 = + %% Line 71 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + when 'true' -> + %% Line 72 + ( case Config of + ( <( {'config',_38,_39,_40,_41,_42,_43,_44,_45,_46,_47,_48,_49,_50,_51,_rec0,_52} + -| ['compiler_generated'] )> when 'true' -> + case _rec0 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_6> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + ([], {'parser',State,Handler,Stack}, _6) + end + -| ['compiler_generated'] ) + ( <_53> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 73 + when 'true' -> + let <_17> = + fun (_15) -> + %% Line 74 + case _15 of + + when let <_8> = + call 'erlang':'=:=' + (_15, 'end_stream') + in let <_9> = + call 'erlang':'=:=' + (_15, 'end_json') + in call 'erlang':'or' + (_8, _9) -> + %% Line 75 + case apply 'resume'/5 + (['end_json'], State, Handler, Stack, Config) of + %% Line 76 + <{'incomplete',_69}> when 'true' -> + ( case Config of + ( <( {'config',_70,_71,_72,_73,_74,_75,_76,_77,_78,_79,_80,_81,_82,_83,_rec1,_84} + -| ['compiler_generated'] )> when 'true' -> + case _rec1 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_12> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + ([], {'parser',State,Handler,Stack}, _12) + end + -| ['compiler_generated'] ) + ( <_85> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 77 + when 'true' -> + Else + end + %% Line 79 + when 'true' -> + %% Line 80 + apply 'resume'/5 + (Tokens, State, Handler, Stack, Config) + end + in %% Line 74 + {'incomplete',_17} + %% Line 83 + when 'true' -> + let <_18> = + call %% Line 84 + 'jsx_config':%% Line 84 + 'config_to_list' + (%% Line 84 + Config) + in %% Line 84 + apply F + ([], {'parser',State,Handler,Stack}, _18) + ( <_22,_21,_20,_19> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_22,_21,_20,_19}) + -| [{'function_name',{'incomplete',4}}] ) + -| ['compiler_generated'] ) + end +'handle_event'/3 = + %% Line 87 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + let <_3> = + call Handler:'handle_event' + (Event, State) + in {Handler,_3} + ( <_6,_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5,_4}) + -| [{'function_name',{'handle_event',3}}] ) + -| ['compiler_generated'] ) + end +'value'/4 = + %% Line 90 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <[String|Tokens],Handler,Stack,Config> + when call 'erlang':'is_binary' + (String) -> + %% Line 91 + try + apply 'clean_string'/2 + (String, Config) + of <_4> -> + let <_5> = + apply %% Line 92 + 'handle_event'/3 + (%% Line 92 + {'string',_4}, %% Line 92 + Handler, %% Line 92 + Config) + in %% Line 92 + apply 'maybe_done'/4 + (Tokens, _5, Stack, Config) + catch <_9,_8,_7> -> + %% Line 93 + case <_9,_8,_7> of + <( 'error' + -| ['compiler_generated'] ),( 'badarg' + -| ['compiler_generated'] ),_74> when 'true' -> + %% Line 94 + ( case Config of + ( <( {'config',_75,_76,_77,_78,_79,_80,_81,_82,_83,_84,_85,_86,_87,_88,_rec2,_89} + -| ['compiler_generated'] )> when 'true' -> + case _rec2 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_12> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + ([{'string',String}|Tokens], {'parser','value',Handler,Stack}, _12) + end + -| ['compiler_generated'] ) + ( <_90> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_111,_112,_113> when 'true' -> + primop 'raise' + (_113, _112) + -| ['compiler_generated'] ) + end + %% Line 96 + <['true'|Tokens],Handler,Stack,Config> when 'true' -> + let <_14> = + apply %% Line 97 + 'handle_event'/3 + (%% Line 97 + {'literal','true'}, %% Line 97 + Handler, %% Line 97 + Config) + in %% Line 97 + apply 'maybe_done'/4 + (Tokens, _14, Stack, Config) + %% Line 98 + <['false'|Tokens],Handler,Stack,Config> when 'true' -> + let <_15> = + apply %% Line 99 + 'handle_event'/3 + (%% Line 99 + {'literal','false'}, %% Line 99 + Handler, %% Line 99 + Config) + in %% Line 99 + apply 'maybe_done'/4 + (Tokens, _15, Stack, Config) + %% Line 100 + <['null'|Tokens],Handler,Stack,Config> when 'true' -> + let <_16> = + apply %% Line 101 + 'handle_event'/3 + (%% Line 101 + {'literal','null'}, %% Line 101 + Handler, %% Line 101 + Config) + in %% Line 101 + apply 'maybe_done'/4 + (Tokens, _16, Stack, Config) + %% Line 102 + <['start_object'|Tokens],Handler,Stack,Config> when 'true' -> + let <_17> = + apply %% Line 103 + 'handle_event'/3 + (%% Line 103 + 'start_object', %% Line 103 + Handler, %% Line 103 + Config) + in %% Line 103 + apply 'object'/4 + (Tokens, _17, ['object'|Stack], Config) + %% Line 104 + <['start_array'|Tokens],Handler,Stack,Config> when 'true' -> + let <_18> = + apply %% Line 105 + 'handle_event'/3 + (%% Line 105 + 'start_array', %% Line 105 + Handler, %% Line 105 + Config) + in %% Line 105 + apply 'array'/4 + (Tokens, _18, ['array'|Stack], Config) + %% Line 106 + <[Number|Tokens],Handler,Stack,Config> + when call 'erlang':'is_integer' + (Number) -> + let <_19> = + apply %% Line 107 + 'handle_event'/3 + (%% Line 107 + {'integer',Number}, %% Line 107 + Handler, %% Line 107 + Config) + in %% Line 107 + apply 'maybe_done'/4 + (Tokens, _19, Stack, Config) + %% Line 108 + <[Number|Tokens],Handler,Stack,Config> + when call 'erlang':'is_float' + (Number) -> + let <_20> = + apply %% Line 109 + 'handle_event'/3 + (%% Line 109 + {'float',Number}, %% Line 109 + Handler, %% Line 109 + Config) + in %% Line 109 + apply 'maybe_done'/4 + (Tokens, _20, Stack, Config) + %% Line 110 + <[{'raw',Raw}|Tokens],Handler,Stack,Config> + when call 'erlang':'is_binary' + (Raw) -> + let <_21> = + call %% Line 111 + 'jsx':%% Line 111 + 'decoder' + (%% Line 111 + 'jsx_parser', %% Line 111 + [], %% Line 111 + []) + in let <_22> = + apply _21 + (%% Line 111 + Raw) + in let <_23> = + call %% Line 111 + 'erlang':%% Line 111 + '++' + (_22, %% Line 111 + Tokens) + in %% Line 111 + apply 'value'/4 + (_23, Handler, Stack, Config) + %% Line 112 + <[Timestamp = {_91,_92,_93}|Tokens],Handler,Stack,Config> when 'true' -> + %% Line 113 + case call 'calendar':'now_to_datetime' + (%% Line 114 + Timestamp) of + <{{Year,Month,Day},{Hour,Min,Sec}}> when 'true' -> + let <_25> = + call %% Line 115 + 'io_lib':%% Line 115 + 'format' + (%% Line 116 + [126|[52|[46|[49|[48|[46|[48|[66|[45|[126|[50|[46|[49|[48|[46|[48|[66|[45|[126|[50|[46|[49|[48|[46|[48|[66|[84|[126|[50|[46|[49|[48|[46|[48|[66|[58|[126|[50|[46|[49|[48|[46|[48|[66|[58|[126|[50|[46|[49|[48|[46|[48|[66|[90]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 117 + [Year|[Month|[Day|[Hour|[Min|[Sec|[]]]]]]]) + in let <_26> = + call %% Line 115 + 'unicode':%% Line 115 + 'characters_to_binary' + (_25) + in %% Line 115 + apply 'value'/4 + ([{'string',_26}|%% Line 118 + Tokens], %% Line 119 + Handler, %% Line 120 + Stack, %% Line 121 + Config) + ( <_24> when 'true' -> + primop 'match_fail' + ({'badmatch',_24}) + -| ['compiler_generated'] ) + end + %% Line 123 + <[{{Year,Month,Day},{Hour,Min,Sec}}|Tokens],Handler,Stack,Config> + when %% Line 124 + try + let <_27> = + call 'erlang':'is_integer' + (Year) + in let <_28> = + call 'erlang':'is_integer' + (Month) + in let <_29> = + call 'erlang':'is_integer' + (Day) + in let <_30> = + call 'erlang':'is_integer' + (Hour) + in let <_31> = + call 'erlang':'is_integer' + (Min) + in let <_32> = + call 'erlang':'is_integer' + (Sec) + in let <_33> = + call 'erlang':'and' + (_31, _32) + in let <_34> = + call 'erlang':'and' + (_30, _33) + in let <_35> = + call 'erlang':'and' + (_29, _34) + in let <_36> = + call 'erlang':'and' + (_28, _35) + in call 'erlang':'and' + (_27, _36) + of -> + Try + catch -> + 'false' -> + let <_37> = + call %% Line 125 + 'io_lib':%% Line 125 + 'format' + (%% Line 126 + [126|[52|[46|[49|[48|[46|[48|[66|[45|[126|[50|[46|[49|[48|[46|[48|[66|[45|[126|[50|[46|[49|[48|[46|[48|[66|[84|[126|[50|[46|[49|[48|[46|[48|[66|[58|[126|[50|[46|[49|[48|[46|[48|[66|[58|[126|[50|[46|[49|[48|[46|[48|[66|[90]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 127 + [Year|[Month|[Day|[Hour|[Min|[Sec|[]]]]]]]) + in let <_38> = + call %% Line 125 + 'unicode':%% Line 125 + 'characters_to_binary' + (_37) + in %% Line 125 + apply 'value'/4 + ([{'string',_38}|%% Line 128 + Tokens], %% Line 129 + Handler, %% Line 130 + Stack, %% Line 131 + Config) + %% Line 133 + <[{{Year,Month,Day},{Hour,Min,Sec}}|Tokens],Handler,Stack,Config> + when %% Line 134 + try + let <_39> = + call 'erlang':'is_integer' + (Year) + in let <_40> = + call 'erlang':'is_integer' + (Month) + in let <_41> = + call 'erlang':'is_integer' + (Day) + in let <_42> = + call 'erlang':'is_integer' + (Hour) + in let <_43> = + call 'erlang':'is_integer' + (Min) + in let <_44> = + call 'erlang':'is_float' + (Sec) + in let <_45> = + call 'erlang':'and' + (_43, _44) + in let <_46> = + call 'erlang':'and' + (_42, _45) + in let <_47> = + call 'erlang':'and' + (_41, _46) + in let <_48> = + call 'erlang':'and' + (_40, _47) + in call 'erlang':'and' + (_39, _48) + of -> + Try + catch -> + 'false' -> + let <_49> = + call %% Line 135 + 'io_lib':%% Line 135 + 'format' + (%% Line 136 + [126|[52|[46|[49|[48|[46|[48|[66|[45|[126|[50|[46|[49|[48|[46|[48|[66|[45|[126|[50|[46|[49|[48|[46|[48|[66|[84|[126|[50|[46|[49|[48|[46|[48|[66|[58|[126|[50|[46|[49|[48|[46|[48|[66|[58|[126|[57|[46|[54|[46|[48|[102|[90]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 137 + [Year|[Month|[Day|[Hour|[Min|[Sec|[]]]]]]]) + in let <_50> = + call %% Line 135 + 'unicode':%% Line 135 + 'characters_to_binary' + (_49) + in %% Line 135 + apply 'value'/4 + ([{'string',_50}|%% Line 138 + Tokens], %% Line 139 + Handler, %% Line 140 + Stack, %% Line 141 + Config) + %% Line 143 + <[{'literal',Value}|Tokens],Handler,Stack,Config> + when let <_51> = + call %% Line 144 + 'erlang':%% Line 144 + '=:=' + (%% Line 144 + Value, %% Line 144 + 'true') + in let <_52> = + call %% Line 144 + 'erlang':%% Line 144 + '=:=' + (%% Line 144 + Value, %% Line 144 + 'false') + in let <_53> = + call %% Line 144 + 'erlang':%% Line 144 + '=:=' + (%% Line 144 + Value, %% Line 144 + 'null') + in let <_54> = + call %% Line 144 + 'erlang':%% Line 144 + 'or' + (_52, _53) + in %% Line 144 + call 'erlang':'or' + (_51, _54) -> + let <_55> = + [%% Line 145 + Value|%% Line 145 + Tokens] + in %% Line 145 + apply 'value'/4 + (_55, Handler, Stack, Config) + %% Line 146 + <[{'integer',Value}|Tokens],Handler,Stack,Config> + when %% Line 147 + call 'erlang':'is_integer' + (Value) -> + let <_56> = + [%% Line 148 + Value|%% Line 148 + Tokens] + in %% Line 148 + apply 'value'/4 + (_56, Handler, Stack, Config) + %% Line 149 + <[{'float',Value}|Tokens],Handler,Stack,Config> + when %% Line 150 + call 'erlang':'is_float' + (Value) -> + let <_57> = + [%% Line 151 + Value|%% Line 151 + Tokens] + in %% Line 151 + apply 'value'/4 + (_57, Handler, Stack, Config) + %% Line 152 + <[{'string',Value}|Tokens],Handler,Stack,Config> + when let <_58> = + call %% Line 153 + 'erlang':%% Line 153 + 'is_binary' + (%% Line 153 + Value) + in let <_59> = + call %% Line 153 + 'erlang':%% Line 153 + 'is_atom' + (%% Line 153 + Value) + in %% Line 153 + call 'erlang':'or' + (_58, _59) -> + let <_60> = + [%% Line 154 + Value|%% Line 154 + Tokens] + in %% Line 154 + apply 'value'/4 + (_60, Handler, Stack, Config) + %% Line 155 + <[{'number',Value}|Tokens],Handler,Stack,Config> + when let <_61> = + call %% Line 156 + 'erlang':%% Line 156 + 'is_float' + (%% Line 156 + Value) + in let <_62> = + call %% Line 156 + 'erlang':%% Line 156 + 'is_integer' + (%% Line 156 + Value) + in %% Line 156 + call 'erlang':'or' + (_61, _62) -> + let <_63> = + [%% Line 157 + Value|%% Line 157 + Tokens] + in %% Line 157 + apply 'value'/4 + (_63, Handler, Stack, Config) + %% Line 158 + <[String|Tokens],Handler,Stack,Config> + when call 'erlang':'is_atom' + (String) -> + let <_64> = + call %% Line 159 + 'erlang':%% Line 159 + 'atom_to_binary' + (%% Line 159 + String, %% Line 159 + 'utf8') + in let <_65> = + [%% Line 159 + {'string',_64}|%% Line 159 + Tokens] + in %% Line 159 + apply 'value'/4 + (_65, Handler, Stack, Config) + %% Line 160 + <[],Handler,Stack,Config> when 'true' -> + %% Line 161 + apply 'incomplete'/4 + ('value', Handler, Stack, Config) + %% Line 162 + + when call 'erlang':'is_list' + (BadTokens) -> + %% Line 163 + ( case Config of + ( <( {'config',_94,_95,_96,_97,_98,_99,_100,_101,_102,_103,_104,_105,_106,_107,_rec3,_108} + -| ['compiler_generated'] )> when 'true' -> + case _rec3 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_68> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (BadTokens, {'parser','value',Handler,Stack}, _68) + end + -| ['compiler_generated'] ) + ( <_109> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 164 + when 'true' -> + %% Line 165 + apply 'value'/4 + ([Token|[]], Handler, Stack, Config) + end +'object'/4 = + %% Line 168 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <['end_object'|Tokens],Handler,['object'|Stack],Config> when 'true' -> + let <_4> = + apply %% Line 169 + 'handle_event'/3 + (%% Line 169 + 'end_object', %% Line 169 + Handler, %% Line 169 + Config) + in %% Line 169 + apply 'maybe_done'/4 + (Tokens, _4, Stack, Config) + %% Line 170 + <[{'key',Key}|Tokens],Handler,Stack,Config> + when let <_5> = + call %% Line 171 + 'erlang':%% Line 171 + 'is_atom' + (%% Line 171 + Key) + in let <_6> = + call %% Line 171 + 'erlang':%% Line 171 + 'is_binary' + (%% Line 171 + Key) + in let <_7> = + call %% Line 171 + 'erlang':%% Line 171 + 'is_integer' + (%% Line 171 + Key) + in let <_8> = + call %% Line 171 + 'erlang':%% Line 171 + 'or' + (_6, _7) + in %% Line 171 + call 'erlang':'or' + (_5, _8) -> + %% Line 172 + apply 'object'/4 + ([Key|Tokens], Handler, Stack, Config) + %% Line 173 + <[Key|Tokens],Handler,_@r0 = ['object'|Stack],Config> + when let <_9> = + call %% Line 174 + 'erlang':%% Line 174 + 'is_atom' + (%% Line 174 + Key) + in let <_10> = + call %% Line 174 + 'erlang':%% Line 174 + 'is_binary' + (%% Line 174 + Key) + in let <_11> = + call %% Line 174 + 'erlang':%% Line 174 + 'is_integer' + (%% Line 174 + Key) + in let <_12> = + call %% Line 174 + 'erlang':%% Line 174 + 'or' + (_10, _11) + in %% Line 174 + call 'erlang':'or' + (_9, _12) -> + %% Line 175 + try + let <_13> = + apply 'fix_key'/1 + (Key) + in apply 'clean_string'/2 + (_13, Config) + of <_14> -> + let <_15> = + apply %% Line 179 + 'handle_event'/3 + (%% Line 179 + {'key',_14}, %% Line 179 + Handler, %% Line 179 + Config) + in %% Line 177 + apply 'value'/4 + (%% Line 178 + Tokens, _15, %% Line 180 + _@r0, %% Line 181 + Config) + catch <_19,_18,_17> -> + %% Line 183 + case <_19,_18,_17> of + <( 'error' + -| ['compiler_generated'] ),( 'badarg' + -| ['compiler_generated'] ),_28> when 'true' -> + %% Line 184 + ( case Config of + ( <( {'config',_29,_30,_31,_32,_33,_34,_35,_36,_37,_38,_39,_40,_41,_42,_rec4,_43} + -| ['compiler_generated'] )> when 'true' -> + case _rec4 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_22> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + ([{'string',Key}|Tokens], {'parser','object',Handler,Stack}, _22) + end + -| ['compiler_generated'] ) + ( <_44> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_46,_47,_48> when 'true' -> + primop 'raise' + (_48, _47) + -| ['compiler_generated'] ) + end + %% Line 186 + <[],Handler,Stack,Config> when 'true' -> + %% Line 187 + apply 'incomplete'/4 + ('object', Handler, Stack, Config) + %% Line 188 + when 'true' -> + %% Line 189 + apply 'object'/4 + ([Token|[]], Handler, Stack, Config) + end +'array'/4 = + %% Line 192 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <['end_array'|Tokens],Handler,['array'|Stack],Config> when 'true' -> + let <_4> = + apply %% Line 193 + 'handle_event'/3 + (%% Line 193 + 'end_array', %% Line 193 + Handler, %% Line 193 + Config) + in %% Line 193 + apply 'maybe_done'/4 + (Tokens, _4, Stack, Config) + %% Line 194 + <[],Handler,Stack,Config> when 'true' -> + %% Line 195 + apply 'incomplete'/4 + ('array', Handler, Stack, Config) + %% Line 196 + + when call 'erlang':'is_list' + (Tokens) -> + %% Line 197 + apply 'value'/4 + (Tokens, Handler, Stack, Config) + %% Line 198 + when 'true' -> + %% Line 199 + apply 'array'/4 + ([Token|[]], Handler, Stack, Config) + end +'maybe_done'/4 = + %% Line 202 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <['end_json'],Handler,[],Config> when 'true' -> + %% Line 203 + apply 'done'/4 + (['end_json'], Handler, [], Config) + %% Line 204 + + when call 'erlang':'is_list' + (Tokens) -> + %% Line 205 + apply 'object'/4 + (Tokens, Handler, Stack, Config) + %% Line 206 + + when call 'erlang':'is_list' + (Tokens) -> + %% Line 207 + apply 'array'/4 + (Tokens, Handler, Stack, Config) + %% Line 208 + <[],Handler,Stack,Config> when 'true' -> + %% Line 209 + apply 'incomplete'/4 + ('maybe_done', Handler, Stack, Config) + %% Line 210 + + when call 'erlang':'is_list' + (BadTokens) -> + %% Line 211 + ( case Config of + ( <( {'config',_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27,_rec5,_28} + -| ['compiler_generated'] )> when 'true' -> + case _rec5 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_6> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (BadTokens, {'parser','maybe_done',Handler,Stack}, _6) + end + -| ['compiler_generated'] ) + ( <_29> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 212 + when 'true' -> + %% Line 213 + apply 'maybe_done'/4 + ([Token|[]], Handler, Stack, Config) + end +'done'/4 = + %% Line 216 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <[],Handler,[],Config = {'config',_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,'true',_25,_26,_27,_28,_29}> when 'true' -> + %% Line 217 + apply 'incomplete'/4 + ('done', Handler, [], Config) + %% Line 218 + + when let <_4> = + call 'erlang':'=:=' + (Tokens, ['end_json']) + in let <_5> = + call 'erlang':'=:=' + (Tokens, []) + in call 'erlang':'or' + (_4, _5) -> + %% Line 219 + case apply 'handle_event'/3 + ('end_json', Handler, Config) of + <{_30,State}> when 'true' -> + %% Line 220 + State + ( <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + -| ['compiler_generated'] ) + end + %% Line 221 + + when call 'erlang':'is_list' + (BadTokens) -> + %% Line 222 + ( case Config of + ( <( {'config',_31,_32,_33,_34,_35,_36,_37,_38,_39,_40,_41,_42,_43,_44,_rec6,_45} + -| ['compiler_generated'] )> when 'true' -> + case _rec6 of + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg') + when 'true' -> + let <_9> = + call 'jsx_config':'config_to_list' + (Config) + in apply F + (BadTokens, {'parser','done',Handler,Stack}, _9) + end + -| ['compiler_generated'] ) + ( <_46> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 223 + when 'true' -> + %% Line 224 + apply 'done'/4 + ([Token|[]], Handler, Stack, Config) + end +'fix_key'/1 = + %% Line 227 + fun (_0) -> + case _0 of + + when call 'erlang':'is_atom' + (_0) -> + call 'erlang':'atom_to_binary' + (Key, 'utf8') + %% Line 228 + + when call 'erlang':'is_integer' + (_0) -> + let <_1> = + call 'erlang':'integer_to_list' + (Key) + in call 'erlang':'list_to_binary' + (_1) + %% Line 229 + + when call 'erlang':'is_binary' + (_0) -> + Key + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'fix_key',1}}] ) + -| ['compiler_generated'] ) + end +'clean_string'/2 = + %% Line 232 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + Bin + %% Line 233 + when 'true' -> + apply 'clean'/3 + (Bin, [], Config) + end +'clean'/3 = + %% Line 237 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <#{#<0>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_3> = + apply %% Line 238 + 'maybe_replace'/2 + (%% Line 238 + 0, %% Line 238 + Config) + in %% Line 238 + apply 'clean'/3 + (Rest, [Acc|[_3|[]]], Config) + %% Line 239 + <#{#<1>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_4> = + apply %% Line 240 + 'maybe_replace'/2 + (%% Line 240 + 1, %% Line 240 + Config) + in %% Line 240 + apply 'clean'/3 + (Rest, [Acc|[_4|[]]], Config) + %% Line 241 + <#{#<2>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_5> = + apply %% Line 242 + 'maybe_replace'/2 + (%% Line 242 + 2, %% Line 242 + Config) + in %% Line 242 + apply 'clean'/3 + (Rest, [Acc|[_5|[]]], Config) + %% Line 243 + <#{#<3>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_6> = + apply %% Line 244 + 'maybe_replace'/2 + (%% Line 244 + 3, %% Line 244 + Config) + in %% Line 244 + apply 'clean'/3 + (Rest, [Acc|[_6|[]]], Config) + %% Line 245 + <#{#<4>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_7> = + apply %% Line 246 + 'maybe_replace'/2 + (%% Line 246 + 4, %% Line 246 + Config) + in %% Line 246 + apply 'clean'/3 + (Rest, [Acc|[_7|[]]], Config) + %% Line 247 + <#{#<5>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_8> = + apply %% Line 248 + 'maybe_replace'/2 + (%% Line 248 + 5, %% Line 248 + Config) + in %% Line 248 + apply 'clean'/3 + (Rest, [Acc|[_8|[]]], Config) + %% Line 249 + <#{#<6>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_9> = + apply %% Line 250 + 'maybe_replace'/2 + (%% Line 250 + 6, %% Line 250 + Config) + in %% Line 250 + apply 'clean'/3 + (Rest, [Acc|[_9|[]]], Config) + %% Line 251 + <#{#<7>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_10> = + apply %% Line 252 + 'maybe_replace'/2 + (%% Line 252 + 7, %% Line 252 + Config) + in %% Line 252 + apply 'clean'/3 + (Rest, [Acc|[_10|[]]], Config) + %% Line 253 + <#{#<8>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_11> = + apply %% Line 254 + 'maybe_replace'/2 + (%% Line 254 + 8, %% Line 254 + Config) + in %% Line 254 + apply 'clean'/3 + (Rest, [Acc|[_11|[]]], Config) + %% Line 255 + <#{#<9>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_12> = + apply %% Line 256 + 'maybe_replace'/2 + (%% Line 256 + 9, %% Line 256 + Config) + in %% Line 256 + apply 'clean'/3 + (Rest, [Acc|[_12|[]]], Config) + %% Line 257 + <#{#<10>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_13> = + apply %% Line 258 + 'maybe_replace'/2 + (%% Line 258 + 10, %% Line 258 + Config) + in %% Line 258 + apply 'clean'/3 + (Rest, [Acc|[_13|[]]], Config) + %% Line 259 + <#{#<11>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_14> = + apply %% Line 260 + 'maybe_replace'/2 + (%% Line 260 + 11, %% Line 260 + Config) + in %% Line 260 + apply 'clean'/3 + (Rest, [Acc|[_14|[]]], Config) + %% Line 261 + <#{#<12>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_15> = + apply %% Line 262 + 'maybe_replace'/2 + (%% Line 262 + 12, %% Line 262 + Config) + in %% Line 262 + apply 'clean'/3 + (Rest, [Acc|[_15|[]]], Config) + %% Line 263 + <#{#<13>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_16> = + apply %% Line 264 + 'maybe_replace'/2 + (%% Line 264 + 13, %% Line 264 + Config) + in %% Line 264 + apply 'clean'/3 + (Rest, [Acc|[_16|[]]], Config) + %% Line 265 + <#{#<14>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_17> = + apply %% Line 266 + 'maybe_replace'/2 + (%% Line 266 + 14, %% Line 266 + Config) + in %% Line 266 + apply 'clean'/3 + (Rest, [Acc|[_17|[]]], Config) + %% Line 267 + <#{#<15>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_18> = + apply %% Line 268 + 'maybe_replace'/2 + (%% Line 268 + 15, %% Line 268 + Config) + in %% Line 268 + apply 'clean'/3 + (Rest, [Acc|[_18|[]]], Config) + %% Line 269 + <#{#<16>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_19> = + apply %% Line 270 + 'maybe_replace'/2 + (%% Line 270 + 16, %% Line 270 + Config) + in %% Line 270 + apply 'clean'/3 + (Rest, [Acc|[_19|[]]], Config) + %% Line 271 + <#{#<17>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_20> = + apply %% Line 272 + 'maybe_replace'/2 + (%% Line 272 + 17, %% Line 272 + Config) + in %% Line 272 + apply 'clean'/3 + (Rest, [Acc|[_20|[]]], Config) + %% Line 273 + <#{#<18>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_21> = + apply %% Line 274 + 'maybe_replace'/2 + (%% Line 274 + 18, %% Line 274 + Config) + in %% Line 274 + apply 'clean'/3 + (Rest, [Acc|[_21|[]]], Config) + %% Line 275 + <#{#<19>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_22> = + apply %% Line 276 + 'maybe_replace'/2 + (%% Line 276 + 19, %% Line 276 + Config) + in %% Line 276 + apply 'clean'/3 + (Rest, [Acc|[_22|[]]], Config) + %% Line 277 + <#{#<20>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_23> = + apply %% Line 278 + 'maybe_replace'/2 + (%% Line 278 + 20, %% Line 278 + Config) + in %% Line 278 + apply 'clean'/3 + (Rest, [Acc|[_23|[]]], Config) + %% Line 279 + <#{#<21>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_24> = + apply %% Line 280 + 'maybe_replace'/2 + (%% Line 280 + 21, %% Line 280 + Config) + in %% Line 280 + apply 'clean'/3 + (Rest, [Acc|[_24|[]]], Config) + %% Line 281 + <#{#<22>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_25> = + apply %% Line 282 + 'maybe_replace'/2 + (%% Line 282 + 22, %% Line 282 + Config) + in %% Line 282 + apply 'clean'/3 + (Rest, [Acc|[_25|[]]], Config) + %% Line 283 + <#{#<23>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_26> = + apply %% Line 284 + 'maybe_replace'/2 + (%% Line 284 + 23, %% Line 284 + Config) + in %% Line 284 + apply 'clean'/3 + (Rest, [Acc|[_26|[]]], Config) + %% Line 285 + <#{#<24>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_27> = + apply %% Line 286 + 'maybe_replace'/2 + (%% Line 286 + 24, %% Line 286 + Config) + in %% Line 286 + apply 'clean'/3 + (Rest, [Acc|[_27|[]]], Config) + %% Line 287 + <#{#<25>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_28> = + apply %% Line 288 + 'maybe_replace'/2 + (%% Line 288 + 25, %% Line 288 + Config) + in %% Line 288 + apply 'clean'/3 + (Rest, [Acc|[_28|[]]], Config) + %% Line 289 + <#{#<26>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_29> = + apply %% Line 290 + 'maybe_replace'/2 + (%% Line 290 + 26, %% Line 290 + Config) + in %% Line 290 + apply 'clean'/3 + (Rest, [Acc|[_29|[]]], Config) + %% Line 291 + <#{#<27>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_30> = + apply %% Line 292 + 'maybe_replace'/2 + (%% Line 292 + 27, %% Line 292 + Config) + in %% Line 292 + apply 'clean'/3 + (Rest, [Acc|[_30|[]]], Config) + %% Line 293 + <#{#<28>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_31> = + apply %% Line 294 + 'maybe_replace'/2 + (%% Line 294 + 28, %% Line 294 + Config) + in %% Line 294 + apply 'clean'/3 + (Rest, [Acc|[_31|[]]], Config) + %% Line 295 + <#{#<29>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_32> = + apply %% Line 296 + 'maybe_replace'/2 + (%% Line 296 + 29, %% Line 296 + Config) + in %% Line 296 + apply 'clean'/3 + (Rest, [Acc|[_32|[]]], Config) + %% Line 297 + <#{#<30>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_33> = + apply %% Line 298 + 'maybe_replace'/2 + (%% Line 298 + 30, %% Line 298 + Config) + in %% Line 298 + apply 'clean'/3 + (Rest, [Acc|[_33|[]]], Config) + %% Line 299 + <#{#<31>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_34> = + apply %% Line 300 + 'maybe_replace'/2 + (%% Line 300 + 31, %% Line 300 + Config) + in %% Line 300 + apply 'clean'/3 + (Rest, [Acc|[_34|[]]], Config) + %% Line 301 + <#{#<34>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_35> = + apply %% Line 302 + 'maybe_replace'/2 + (%% Line 302 + 34, %% Line 302 + Config) + in %% Line 302 + apply 'clean'/3 + (Rest, [Acc|[_35|[]]], Config) + %% Line 303 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_36> = + apply %% Line 304 + 'maybe_replace'/2 + (%% Line 304 + 47, %% Line 304 + Config) + in %% Line 304 + apply 'clean'/3 + (Rest, [Acc|[_36|[]]], Config) + %% Line 305 + <#{#<92>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_37> = + apply %% Line 306 + 'maybe_replace'/2 + (%% Line 306 + 92, %% Line 306 + Config) + in %% Line 306 + apply 'clean'/3 + (Rest, [Acc|[_37|[]]], Config) + %% Line 307 + ('undefined','undefined','utf8',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config = {'config',_59,_60,_61,_62,_63,_64,_65,_66,_67,_68,_69,_70,'true',_71,_72,_73}> when 'true' -> + %% Line 308 + case X of + %% Line 309 + <_74> + when call 'erlang':'<' + (X, + 128) -> + apply 'start_count'/3 + (Bin, Acc, Config) + %% Line 310 + <_77> when 'true' -> + let <_38> = + apply 'json_escape_sequence'/1 + (X) + in apply 'clean'/3 + (Rest, [Acc|[_38|[]]], Config) + end + %% Line 313 + <#{#<226>(8,1,'integer',['unsigned'|['big']]), + #<128>(8,1,'integer',['unsigned'|['big']]), + #<168>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_40> = + apply %% Line 314 + 'maybe_replace'/2 + (%% Line 314 + 8232, %% Line 314 + Config) + in %% Line 314 + apply 'clean'/3 + (Rest, [Acc|[_40|[]]], Config) + %% Line 316 + <#{#<226>(8,1,'integer',['unsigned'|['big']]), + #<128>(8,1,'integer',['unsigned'|['big']]), + #<169>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_41> = + apply %% Line 317 + 'maybe_replace'/2 + (%% Line 317 + 8233, %% Line 317 + Config) + in %% Line 317 + apply 'clean'/3 + (Rest, [Acc|[_41|[]]], Config) + %% Line 318 + ('undefined','undefined','utf8',['unsigned'|['big']]), + #<_79>('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + apply 'start_count'/3 + (Bin, Acc, Config) + %% Line 320 + <#{#<237>(8,1,'integer',['unsigned'|['big']]), + #(8,1,'integer',['unsigned'|['big']]), + #<_80>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> + when call 'erlang':'>=' + (X, + 160) -> + let <_42> = + apply %% Line 321 + 'maybe_replace'/2 + (%% Line 321 + 'surrogate', %% Line 321 + Config) + in %% Line 321 + apply 'clean'/3 + (Rest, [Acc|[_42|[]]], Config) + %% Line 323 + <#{#(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> + when let <_43> = + call 'erlang':'>=' + (X, 192) + in let <_44> = + call 'erlang':'=<' + (X, 223) + in call 'erlang':'and' + (_43, _44) -> + let <_46> = + apply %% Line 324 + 'strip_continuations'/2 + (%% Line 324 + Rest, %% Line 324 + 1) + in let <_45> = + apply %% Line 324 + 'maybe_replace'/2 + (%% Line 324 + 'badutf', %% Line 324 + Config) + in %% Line 324 + apply 'clean'/3 + (_46, [Acc|[_45|[]]], Config) + %% Line 326 + <#{#(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> + when let <_47> = + call 'erlang':'>=' + (X, 224) + in let <_48> = + call 'erlang':'=<' + (X, 239) + in call 'erlang':'and' + (_47, _48) -> + let <_50> = + apply %% Line 327 + 'strip_continuations'/2 + (%% Line 327 + Rest, %% Line 327 + 2) + in let <_49> = + apply %% Line 327 + 'maybe_replace'/2 + (%% Line 327 + 'badutf', %% Line 327 + Config) + in %% Line 327 + apply 'clean'/3 + (_50, [Acc|[_49|[]]], Config) + %% Line 329 + <#{#(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> + when let <_51> = + call 'erlang':'>=' + (X, 240) + in let <_52> = + call 'erlang':'=<' + (X, 247) + in call 'erlang':'and' + (_51, _52) -> + let <_54> = + apply %% Line 330 + 'strip_continuations'/2 + (%% Line 330 + Rest, %% Line 330 + 3) + in let <_53> = + apply %% Line 330 + 'maybe_replace'/2 + (%% Line 330 + 'badutf', %% Line 330 + Config) + in %% Line 330 + apply 'clean'/3 + (_54, [Acc|[_53|[]]], Config) + %% Line 331 + <#{#<_81>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,Acc,Config> when 'true' -> + let <_55> = + apply %% Line 332 + 'maybe_replace'/2 + (%% Line 332 + 'badutf', %% Line 332 + Config) + in %% Line 332 + apply 'clean'/3 + (Rest, [Acc|[_55|[]]], Config) + %% Line 333 + <#{}#,Acc,_82> when 'true' -> + call 'erlang':'iolist_to_binary' + (Acc) + ( <_58,_57,_56> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_58,_57,_56}) + -| [{'function_name',{'clean',3}}] ) + -| ['compiler_generated'] ) + end +'start_count'/3 = + %% Line 336 + fun (_0,_1,_2) -> + let = + apply %% Line 337 + 'count'/3 + (_0, %% Line 337 + 0, _2) + in %% Line 338 + case _0 of + <#{#(Size,8,'binary',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#> when 'true' -> + %% Line 339 + apply 'clean'/3 + (Rest, [_1|[Clean|[]]], _2) + ( <_4> when 'true' -> + primop 'match_fail' + ({'badmatch',_4}) + -| ['compiler_generated'] ) + end +'count'/3 = + %% Line 343 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <#{#<0>(8,1,'integer',['unsigned'|['big']]), + #<_103>('all',8,'binary',['unsigned'|['big']])}#,N,_104> when 'true' -> + N + %% Line 344 + <#{#<1>(8,1,'integer',['unsigned'|['big']]), + #<_105>('all',8,'binary',['unsigned'|['big']])}#,N,_106> when 'true' -> + N + %% Line 345 + <#{#<2>(8,1,'integer',['unsigned'|['big']]), + #<_107>('all',8,'binary',['unsigned'|['big']])}#,N,_108> when 'true' -> + N + %% Line 346 + <#{#<3>(8,1,'integer',['unsigned'|['big']]), + #<_109>('all',8,'binary',['unsigned'|['big']])}#,N,_110> when 'true' -> + N + %% Line 347 + <#{#<4>(8,1,'integer',['unsigned'|['big']]), + #<_111>('all',8,'binary',['unsigned'|['big']])}#,N,_112> when 'true' -> + N + %% Line 348 + <#{#<5>(8,1,'integer',['unsigned'|['big']]), + #<_113>('all',8,'binary',['unsigned'|['big']])}#,N,_114> when 'true' -> + N + %% Line 349 + <#{#<6>(8,1,'integer',['unsigned'|['big']]), + #<_115>('all',8,'binary',['unsigned'|['big']])}#,N,_116> when 'true' -> + N + %% Line 350 + <#{#<7>(8,1,'integer',['unsigned'|['big']]), + #<_117>('all',8,'binary',['unsigned'|['big']])}#,N,_118> when 'true' -> + N + %% Line 351 + <#{#<8>(8,1,'integer',['unsigned'|['big']]), + #<_119>('all',8,'binary',['unsigned'|['big']])}#,N,_120> when 'true' -> + N + %% Line 352 + <#{#<9>(8,1,'integer',['unsigned'|['big']]), + #<_121>('all',8,'binary',['unsigned'|['big']])}#,N,_122> when 'true' -> + N + %% Line 353 + <#{#<10>(8,1,'integer',['unsigned'|['big']]), + #<_123>('all',8,'binary',['unsigned'|['big']])}#,N,_124> when 'true' -> + N + %% Line 354 + <#{#<11>(8,1,'integer',['unsigned'|['big']]), + #<_125>('all',8,'binary',['unsigned'|['big']])}#,N,_126> when 'true' -> + N + %% Line 355 + <#{#<12>(8,1,'integer',['unsigned'|['big']]), + #<_127>('all',8,'binary',['unsigned'|['big']])}#,N,_128> when 'true' -> + N + %% Line 356 + <#{#<13>(8,1,'integer',['unsigned'|['big']]), + #<_129>('all',8,'binary',['unsigned'|['big']])}#,N,_130> when 'true' -> + N + %% Line 357 + <#{#<14>(8,1,'integer',['unsigned'|['big']]), + #<_131>('all',8,'binary',['unsigned'|['big']])}#,N,_132> when 'true' -> + N + %% Line 358 + <#{#<15>(8,1,'integer',['unsigned'|['big']]), + #<_133>('all',8,'binary',['unsigned'|['big']])}#,N,_134> when 'true' -> + N + %% Line 359 + <#{#<16>(8,1,'integer',['unsigned'|['big']]), + #<_135>('all',8,'binary',['unsigned'|['big']])}#,N,_136> when 'true' -> + N + %% Line 360 + <#{#<17>(8,1,'integer',['unsigned'|['big']]), + #<_137>('all',8,'binary',['unsigned'|['big']])}#,N,_138> when 'true' -> + N + %% Line 361 + <#{#<18>(8,1,'integer',['unsigned'|['big']]), + #<_139>('all',8,'binary',['unsigned'|['big']])}#,N,_140> when 'true' -> + N + %% Line 362 + <#{#<19>(8,1,'integer',['unsigned'|['big']]), + #<_141>('all',8,'binary',['unsigned'|['big']])}#,N,_142> when 'true' -> + N + %% Line 363 + <#{#<20>(8,1,'integer',['unsigned'|['big']]), + #<_143>('all',8,'binary',['unsigned'|['big']])}#,N,_144> when 'true' -> + N + %% Line 364 + <#{#<21>(8,1,'integer',['unsigned'|['big']]), + #<_145>('all',8,'binary',['unsigned'|['big']])}#,N,_146> when 'true' -> + N + %% Line 365 + <#{#<22>(8,1,'integer',['unsigned'|['big']]), + #<_147>('all',8,'binary',['unsigned'|['big']])}#,N,_148> when 'true' -> + N + %% Line 366 + <#{#<23>(8,1,'integer',['unsigned'|['big']]), + #<_149>('all',8,'binary',['unsigned'|['big']])}#,N,_150> when 'true' -> + N + %% Line 367 + <#{#<24>(8,1,'integer',['unsigned'|['big']]), + #<_151>('all',8,'binary',['unsigned'|['big']])}#,N,_152> when 'true' -> + N + %% Line 368 + <#{#<25>(8,1,'integer',['unsigned'|['big']]), + #<_153>('all',8,'binary',['unsigned'|['big']])}#,N,_154> when 'true' -> + N + %% Line 369 + <#{#<26>(8,1,'integer',['unsigned'|['big']]), + #<_155>('all',8,'binary',['unsigned'|['big']])}#,N,_156> when 'true' -> + N + %% Line 370 + <#{#<27>(8,1,'integer',['unsigned'|['big']]), + #<_157>('all',8,'binary',['unsigned'|['big']])}#,N,_158> when 'true' -> + N + %% Line 371 + <#{#<28>(8,1,'integer',['unsigned'|['big']]), + #<_159>('all',8,'binary',['unsigned'|['big']])}#,N,_160> when 'true' -> + N + %% Line 372 + <#{#<29>(8,1,'integer',['unsigned'|['big']]), + #<_161>('all',8,'binary',['unsigned'|['big']])}#,N,_162> when 'true' -> + N + %% Line 373 + <#{#<30>(8,1,'integer',['unsigned'|['big']]), + #<_163>('all',8,'binary',['unsigned'|['big']])}#,N,_164> when 'true' -> + N + %% Line 374 + <#{#<31>(8,1,'integer',['unsigned'|['big']]), + #<_165>('all',8,'binary',['unsigned'|['big']])}#,N,_166> when 'true' -> + N + %% Line 375 + <#{#<32>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_3> = + call %% Line 376 + 'erlang':%% Line 376 + '+' + (%% Line 376 + N, %% Line 376 + 1) + in %% Line 376 + apply 'count'/3 + (Rest, _3, Config) + %% Line 377 + <#{#<33>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_4> = + call %% Line 378 + 'erlang':%% Line 378 + '+' + (%% Line 378 + N, %% Line 378 + 1) + in %% Line 378 + apply 'count'/3 + (Rest, _4, Config) + %% Line 379 + <#{#<34>(8,1,'integer',['unsigned'|['big']]), + #<_167>('all',8,'binary',['unsigned'|['big']])}#,N,_168> when 'true' -> + N + %% Line 380 + <#{#<35>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_5> = + call %% Line 381 + 'erlang':%% Line 381 + '+' + (%% Line 381 + N, %% Line 381 + 1) + in %% Line 381 + apply 'count'/3 + (Rest, _5, Config) + %% Line 382 + <#{#<36>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_6> = + call %% Line 383 + 'erlang':%% Line 383 + '+' + (%% Line 383 + N, %% Line 383 + 1) + in %% Line 383 + apply 'count'/3 + (Rest, _6, Config) + %% Line 384 + <#{#<37>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_7> = + call %% Line 385 + 'erlang':%% Line 385 + '+' + (%% Line 385 + N, %% Line 385 + 1) + in %% Line 385 + apply 'count'/3 + (Rest, _7, Config) + %% Line 386 + <#{#<38>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_8> = + call %% Line 387 + 'erlang':%% Line 387 + '+' + (%% Line 387 + N, %% Line 387 + 1) + in %% Line 387 + apply 'count'/3 + (Rest, _8, Config) + %% Line 388 + <#{#<39>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_9> = + call %% Line 389 + 'erlang':%% Line 389 + '+' + (%% Line 389 + N, %% Line 389 + 1) + in %% Line 389 + apply 'count'/3 + (Rest, _9, Config) + %% Line 390 + <#{#<40>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_10> = + call %% Line 391 + 'erlang':%% Line 391 + '+' + (%% Line 391 + N, %% Line 391 + 1) + in %% Line 391 + apply 'count'/3 + (Rest, _10, Config) + %% Line 392 + <#{#<41>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_11> = + call %% Line 393 + 'erlang':%% Line 393 + '+' + (%% Line 393 + N, %% Line 393 + 1) + in %% Line 393 + apply 'count'/3 + (Rest, _11, Config) + %% Line 394 + <#{#<42>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_12> = + call %% Line 395 + 'erlang':%% Line 395 + '+' + (%% Line 395 + N, %% Line 395 + 1) + in %% Line 395 + apply 'count'/3 + (Rest, _12, Config) + %% Line 396 + <#{#<43>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_13> = + call %% Line 397 + 'erlang':%% Line 397 + '+' + (%% Line 397 + N, %% Line 397 + 1) + in %% Line 397 + apply 'count'/3 + (Rest, _13, Config) + %% Line 398 + <#{#<44>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_14> = + call %% Line 399 + 'erlang':%% Line 399 + '+' + (%% Line 399 + N, %% Line 399 + 1) + in %% Line 399 + apply 'count'/3 + (Rest, _14, Config) + %% Line 400 + <#{#<45>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_15> = + call %% Line 401 + 'erlang':%% Line 401 + '+' + (%% Line 401 + N, %% Line 401 + 1) + in %% Line 401 + apply 'count'/3 + (Rest, _15, Config) + %% Line 402 + <#{#<46>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_16> = + call %% Line 403 + 'erlang':%% Line 403 + '+' + (%% Line 403 + N, %% Line 403 + 1) + in %% Line 403 + apply 'count'/3 + (Rest, _16, Config) + %% Line 404 + <#{#<47>(8,1,'integer',['unsigned'|['big']]), + #<_169>('all',8,'binary',['unsigned'|['big']])}#,N,_170> when 'true' -> + N + %% Line 405 + <#{#<48>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_17> = + call %% Line 406 + 'erlang':%% Line 406 + '+' + (%% Line 406 + N, %% Line 406 + 1) + in %% Line 406 + apply 'count'/3 + (Rest, _17, Config) + %% Line 407 + <#{#<49>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_18> = + call %% Line 408 + 'erlang':%% Line 408 + '+' + (%% Line 408 + N, %% Line 408 + 1) + in %% Line 408 + apply 'count'/3 + (Rest, _18, Config) + %% Line 409 + <#{#<50>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_19> = + call %% Line 410 + 'erlang':%% Line 410 + '+' + (%% Line 410 + N, %% Line 410 + 1) + in %% Line 410 + apply 'count'/3 + (Rest, _19, Config) + %% Line 411 + <#{#<51>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_20> = + call %% Line 412 + 'erlang':%% Line 412 + '+' + (%% Line 412 + N, %% Line 412 + 1) + in %% Line 412 + apply 'count'/3 + (Rest, _20, Config) + %% Line 413 + <#{#<52>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_21> = + call %% Line 414 + 'erlang':%% Line 414 + '+' + (%% Line 414 + N, %% Line 414 + 1) + in %% Line 414 + apply 'count'/3 + (Rest, _21, Config) + %% Line 415 + <#{#<53>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_22> = + call %% Line 416 + 'erlang':%% Line 416 + '+' + (%% Line 416 + N, %% Line 416 + 1) + in %% Line 416 + apply 'count'/3 + (Rest, _22, Config) + %% Line 417 + <#{#<54>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_23> = + call %% Line 418 + 'erlang':%% Line 418 + '+' + (%% Line 418 + N, %% Line 418 + 1) + in %% Line 418 + apply 'count'/3 + (Rest, _23, Config) + %% Line 419 + <#{#<55>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_24> = + call %% Line 420 + 'erlang':%% Line 420 + '+' + (%% Line 420 + N, %% Line 420 + 1) + in %% Line 420 + apply 'count'/3 + (Rest, _24, Config) + %% Line 421 + <#{#<56>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_25> = + call %% Line 422 + 'erlang':%% Line 422 + '+' + (%% Line 422 + N, %% Line 422 + 1) + in %% Line 422 + apply 'count'/3 + (Rest, _25, Config) + %% Line 423 + <#{#<57>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_26> = + call %% Line 424 + 'erlang':%% Line 424 + '+' + (%% Line 424 + N, %% Line 424 + 1) + in %% Line 424 + apply 'count'/3 + (Rest, _26, Config) + %% Line 425 + <#{#<58>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_27> = + call %% Line 426 + 'erlang':%% Line 426 + '+' + (%% Line 426 + N, %% Line 426 + 1) + in %% Line 426 + apply 'count'/3 + (Rest, _27, Config) + %% Line 427 + <#{#<59>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_28> = + call %% Line 428 + 'erlang':%% Line 428 + '+' + (%% Line 428 + N, %% Line 428 + 1) + in %% Line 428 + apply 'count'/3 + (Rest, _28, Config) + %% Line 429 + <#{#<60>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_29> = + call %% Line 430 + 'erlang':%% Line 430 + '+' + (%% Line 430 + N, %% Line 430 + 1) + in %% Line 430 + apply 'count'/3 + (Rest, _29, Config) + %% Line 431 + <#{#<61>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_30> = + call %% Line 432 + 'erlang':%% Line 432 + '+' + (%% Line 432 + N, %% Line 432 + 1) + in %% Line 432 + apply 'count'/3 + (Rest, _30, Config) + %% Line 433 + <#{#<62>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_31> = + call %% Line 434 + 'erlang':%% Line 434 + '+' + (%% Line 434 + N, %% Line 434 + 1) + in %% Line 434 + apply 'count'/3 + (Rest, _31, Config) + %% Line 435 + <#{#<63>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_32> = + call %% Line 436 + 'erlang':%% Line 436 + '+' + (%% Line 436 + N, %% Line 436 + 1) + in %% Line 436 + apply 'count'/3 + (Rest, _32, Config) + %% Line 437 + <#{#<64>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_33> = + call %% Line 438 + 'erlang':%% Line 438 + '+' + (%% Line 438 + N, %% Line 438 + 1) + in %% Line 438 + apply 'count'/3 + (Rest, _33, Config) + %% Line 439 + <#{#<65>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_34> = + call %% Line 440 + 'erlang':%% Line 440 + '+' + (%% Line 440 + N, %% Line 440 + 1) + in %% Line 440 + apply 'count'/3 + (Rest, _34, Config) + %% Line 441 + <#{#<66>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_35> = + call %% Line 442 + 'erlang':%% Line 442 + '+' + (%% Line 442 + N, %% Line 442 + 1) + in %% Line 442 + apply 'count'/3 + (Rest, _35, Config) + %% Line 443 + <#{#<67>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_36> = + call %% Line 444 + 'erlang':%% Line 444 + '+' + (%% Line 444 + N, %% Line 444 + 1) + in %% Line 444 + apply 'count'/3 + (Rest, _36, Config) + %% Line 445 + <#{#<68>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_37> = + call %% Line 446 + 'erlang':%% Line 446 + '+' + (%% Line 446 + N, %% Line 446 + 1) + in %% Line 446 + apply 'count'/3 + (Rest, _37, Config) + %% Line 447 + <#{#<69>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_38> = + call %% Line 448 + 'erlang':%% Line 448 + '+' + (%% Line 448 + N, %% Line 448 + 1) + in %% Line 448 + apply 'count'/3 + (Rest, _38, Config) + %% Line 449 + <#{#<70>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_39> = + call %% Line 450 + 'erlang':%% Line 450 + '+' + (%% Line 450 + N, %% Line 450 + 1) + in %% Line 450 + apply 'count'/3 + (Rest, _39, Config) + %% Line 451 + <#{#<71>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_40> = + call %% Line 452 + 'erlang':%% Line 452 + '+' + (%% Line 452 + N, %% Line 452 + 1) + in %% Line 452 + apply 'count'/3 + (Rest, _40, Config) + %% Line 453 + <#{#<72>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_41> = + call %% Line 454 + 'erlang':%% Line 454 + '+' + (%% Line 454 + N, %% Line 454 + 1) + in %% Line 454 + apply 'count'/3 + (Rest, _41, Config) + %% Line 455 + <#{#<73>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_42> = + call %% Line 456 + 'erlang':%% Line 456 + '+' + (%% Line 456 + N, %% Line 456 + 1) + in %% Line 456 + apply 'count'/3 + (Rest, _42, Config) + %% Line 457 + <#{#<74>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_43> = + call %% Line 458 + 'erlang':%% Line 458 + '+' + (%% Line 458 + N, %% Line 458 + 1) + in %% Line 458 + apply 'count'/3 + (Rest, _43, Config) + %% Line 459 + <#{#<75>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_44> = + call %% Line 460 + 'erlang':%% Line 460 + '+' + (%% Line 460 + N, %% Line 460 + 1) + in %% Line 460 + apply 'count'/3 + (Rest, _44, Config) + %% Line 461 + <#{#<76>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_45> = + call %% Line 462 + 'erlang':%% Line 462 + '+' + (%% Line 462 + N, %% Line 462 + 1) + in %% Line 462 + apply 'count'/3 + (Rest, _45, Config) + %% Line 463 + <#{#<77>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_46> = + call %% Line 464 + 'erlang':%% Line 464 + '+' + (%% Line 464 + N, %% Line 464 + 1) + in %% Line 464 + apply 'count'/3 + (Rest, _46, Config) + %% Line 465 + <#{#<78>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_47> = + call %% Line 466 + 'erlang':%% Line 466 + '+' + (%% Line 466 + N, %% Line 466 + 1) + in %% Line 466 + apply 'count'/3 + (Rest, _47, Config) + %% Line 467 + <#{#<79>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_48> = + call %% Line 468 + 'erlang':%% Line 468 + '+' + (%% Line 468 + N, %% Line 468 + 1) + in %% Line 468 + apply 'count'/3 + (Rest, _48, Config) + %% Line 469 + <#{#<80>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_49> = + call %% Line 470 + 'erlang':%% Line 470 + '+' + (%% Line 470 + N, %% Line 470 + 1) + in %% Line 470 + apply 'count'/3 + (Rest, _49, Config) + %% Line 471 + <#{#<81>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_50> = + call %% Line 472 + 'erlang':%% Line 472 + '+' + (%% Line 472 + N, %% Line 472 + 1) + in %% Line 472 + apply 'count'/3 + (Rest, _50, Config) + %% Line 473 + <#{#<82>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_51> = + call %% Line 474 + 'erlang':%% Line 474 + '+' + (%% Line 474 + N, %% Line 474 + 1) + in %% Line 474 + apply 'count'/3 + (Rest, _51, Config) + %% Line 475 + <#{#<83>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_52> = + call %% Line 476 + 'erlang':%% Line 476 + '+' + (%% Line 476 + N, %% Line 476 + 1) + in %% Line 476 + apply 'count'/3 + (Rest, _52, Config) + %% Line 477 + <#{#<84>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_53> = + call %% Line 478 + 'erlang':%% Line 478 + '+' + (%% Line 478 + N, %% Line 478 + 1) + in %% Line 478 + apply 'count'/3 + (Rest, _53, Config) + %% Line 479 + <#{#<85>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_54> = + call %% Line 480 + 'erlang':%% Line 480 + '+' + (%% Line 480 + N, %% Line 480 + 1) + in %% Line 480 + apply 'count'/3 + (Rest, _54, Config) + %% Line 481 + <#{#<86>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_55> = + call %% Line 482 + 'erlang':%% Line 482 + '+' + (%% Line 482 + N, %% Line 482 + 1) + in %% Line 482 + apply 'count'/3 + (Rest, _55, Config) + %% Line 483 + <#{#<87>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_56> = + call %% Line 484 + 'erlang':%% Line 484 + '+' + (%% Line 484 + N, %% Line 484 + 1) + in %% Line 484 + apply 'count'/3 + (Rest, _56, Config) + %% Line 485 + <#{#<88>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_57> = + call %% Line 486 + 'erlang':%% Line 486 + '+' + (%% Line 486 + N, %% Line 486 + 1) + in %% Line 486 + apply 'count'/3 + (Rest, _57, Config) + %% Line 487 + <#{#<89>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_58> = + call %% Line 488 + 'erlang':%% Line 488 + '+' + (%% Line 488 + N, %% Line 488 + 1) + in %% Line 488 + apply 'count'/3 + (Rest, _58, Config) + %% Line 489 + <#{#<90>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_59> = + call %% Line 490 + 'erlang':%% Line 490 + '+' + (%% Line 490 + N, %% Line 490 + 1) + in %% Line 490 + apply 'count'/3 + (Rest, _59, Config) + %% Line 491 + <#{#<91>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_60> = + call %% Line 492 + 'erlang':%% Line 492 + '+' + (%% Line 492 + N, %% Line 492 + 1) + in %% Line 492 + apply 'count'/3 + (Rest, _60, Config) + %% Line 493 + <#{#<92>(8,1,'integer',['unsigned'|['big']]), + #<_171>('all',8,'binary',['unsigned'|['big']])}#,N,_172> when 'true' -> + N + %% Line 494 + <#{#<93>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_61> = + call %% Line 495 + 'erlang':%% Line 495 + '+' + (%% Line 495 + N, %% Line 495 + 1) + in %% Line 495 + apply 'count'/3 + (Rest, _61, Config) + %% Line 496 + <#{#<94>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_62> = + call %% Line 497 + 'erlang':%% Line 497 + '+' + (%% Line 497 + N, %% Line 497 + 1) + in %% Line 497 + apply 'count'/3 + (Rest, _62, Config) + %% Line 498 + <#{#<95>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_63> = + call %% Line 499 + 'erlang':%% Line 499 + '+' + (%% Line 499 + N, %% Line 499 + 1) + in %% Line 499 + apply 'count'/3 + (Rest, _63, Config) + %% Line 500 + <#{#<96>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_64> = + call %% Line 501 + 'erlang':%% Line 501 + '+' + (%% Line 501 + N, %% Line 501 + 1) + in %% Line 501 + apply 'count'/3 + (Rest, _64, Config) + %% Line 502 + <#{#<97>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_65> = + call %% Line 503 + 'erlang':%% Line 503 + '+' + (%% Line 503 + N, %% Line 503 + 1) + in %% Line 503 + apply 'count'/3 + (Rest, _65, Config) + %% Line 504 + <#{#<98>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_66> = + call %% Line 505 + 'erlang':%% Line 505 + '+' + (%% Line 505 + N, %% Line 505 + 1) + in %% Line 505 + apply 'count'/3 + (Rest, _66, Config) + %% Line 506 + <#{#<99>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_67> = + call %% Line 507 + 'erlang':%% Line 507 + '+' + (%% Line 507 + N, %% Line 507 + 1) + in %% Line 507 + apply 'count'/3 + (Rest, _67, Config) + %% Line 508 + <#{#<100>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_68> = + call %% Line 509 + 'erlang':%% Line 509 + '+' + (%% Line 509 + N, %% Line 509 + 1) + in %% Line 509 + apply 'count'/3 + (Rest, _68, Config) + %% Line 510 + <#{#<101>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_69> = + call %% Line 511 + 'erlang':%% Line 511 + '+' + (%% Line 511 + N, %% Line 511 + 1) + in %% Line 511 + apply 'count'/3 + (Rest, _69, Config) + %% Line 512 + <#{#<102>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_70> = + call %% Line 513 + 'erlang':%% Line 513 + '+' + (%% Line 513 + N, %% Line 513 + 1) + in %% Line 513 + apply 'count'/3 + (Rest, _70, Config) + %% Line 514 + <#{#<103>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_71> = + call %% Line 515 + 'erlang':%% Line 515 + '+' + (%% Line 515 + N, %% Line 515 + 1) + in %% Line 515 + apply 'count'/3 + (Rest, _71, Config) + %% Line 516 + <#{#<104>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_72> = + call %% Line 517 + 'erlang':%% Line 517 + '+' + (%% Line 517 + N, %% Line 517 + 1) + in %% Line 517 + apply 'count'/3 + (Rest, _72, Config) + %% Line 518 + <#{#<105>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_73> = + call %% Line 519 + 'erlang':%% Line 519 + '+' + (%% Line 519 + N, %% Line 519 + 1) + in %% Line 519 + apply 'count'/3 + (Rest, _73, Config) + %% Line 520 + <#{#<106>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_74> = + call %% Line 521 + 'erlang':%% Line 521 + '+' + (%% Line 521 + N, %% Line 521 + 1) + in %% Line 521 + apply 'count'/3 + (Rest, _74, Config) + %% Line 522 + <#{#<107>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_75> = + call %% Line 523 + 'erlang':%% Line 523 + '+' + (%% Line 523 + N, %% Line 523 + 1) + in %% Line 523 + apply 'count'/3 + (Rest, _75, Config) + %% Line 524 + <#{#<108>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_76> = + call %% Line 525 + 'erlang':%% Line 525 + '+' + (%% Line 525 + N, %% Line 525 + 1) + in %% Line 525 + apply 'count'/3 + (Rest, _76, Config) + %% Line 526 + <#{#<109>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_77> = + call %% Line 527 + 'erlang':%% Line 527 + '+' + (%% Line 527 + N, %% Line 527 + 1) + in %% Line 527 + apply 'count'/3 + (Rest, _77, Config) + %% Line 528 + <#{#<110>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_78> = + call %% Line 529 + 'erlang':%% Line 529 + '+' + (%% Line 529 + N, %% Line 529 + 1) + in %% Line 529 + apply 'count'/3 + (Rest, _78, Config) + %% Line 530 + <#{#<111>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_79> = + call %% Line 531 + 'erlang':%% Line 531 + '+' + (%% Line 531 + N, %% Line 531 + 1) + in %% Line 531 + apply 'count'/3 + (Rest, _79, Config) + %% Line 532 + <#{#<112>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_80> = + call %% Line 533 + 'erlang':%% Line 533 + '+' + (%% Line 533 + N, %% Line 533 + 1) + in %% Line 533 + apply 'count'/3 + (Rest, _80, Config) + %% Line 534 + <#{#<113>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_81> = + call %% Line 535 + 'erlang':%% Line 535 + '+' + (%% Line 535 + N, %% Line 535 + 1) + in %% Line 535 + apply 'count'/3 + (Rest, _81, Config) + %% Line 536 + <#{#<114>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_82> = + call %% Line 537 + 'erlang':%% Line 537 + '+' + (%% Line 537 + N, %% Line 537 + 1) + in %% Line 537 + apply 'count'/3 + (Rest, _82, Config) + %% Line 538 + <#{#<115>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_83> = + call %% Line 539 + 'erlang':%% Line 539 + '+' + (%% Line 539 + N, %% Line 539 + 1) + in %% Line 539 + apply 'count'/3 + (Rest, _83, Config) + %% Line 540 + <#{#<116>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_84> = + call %% Line 541 + 'erlang':%% Line 541 + '+' + (%% Line 541 + N, %% Line 541 + 1) + in %% Line 541 + apply 'count'/3 + (Rest, _84, Config) + %% Line 542 + <#{#<117>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_85> = + call %% Line 543 + 'erlang':%% Line 543 + '+' + (%% Line 543 + N, %% Line 543 + 1) + in %% Line 543 + apply 'count'/3 + (Rest, _85, Config) + %% Line 544 + <#{#<118>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_86> = + call %% Line 545 + 'erlang':%% Line 545 + '+' + (%% Line 545 + N, %% Line 545 + 1) + in %% Line 545 + apply 'count'/3 + (Rest, _86, Config) + %% Line 546 + <#{#<119>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_87> = + call %% Line 547 + 'erlang':%% Line 547 + '+' + (%% Line 547 + N, %% Line 547 + 1) + in %% Line 547 + apply 'count'/3 + (Rest, _87, Config) + %% Line 548 + <#{#<120>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_88> = + call %% Line 549 + 'erlang':%% Line 549 + '+' + (%% Line 549 + N, %% Line 549 + 1) + in %% Line 549 + apply 'count'/3 + (Rest, _88, Config) + %% Line 550 + <#{#<121>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_89> = + call %% Line 551 + 'erlang':%% Line 551 + '+' + (%% Line 551 + N, %% Line 551 + 1) + in %% Line 551 + apply 'count'/3 + (Rest, _89, Config) + %% Line 552 + <#{#<122>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_90> = + call %% Line 553 + 'erlang':%% Line 553 + '+' + (%% Line 553 + N, %% Line 553 + 1) + in %% Line 553 + apply 'count'/3 + (Rest, _90, Config) + %% Line 554 + <#{#<123>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_91> = + call %% Line 555 + 'erlang':%% Line 555 + '+' + (%% Line 555 + N, %% Line 555 + 1) + in %% Line 555 + apply 'count'/3 + (Rest, _91, Config) + %% Line 556 + <#{#<124>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_92> = + call %% Line 557 + 'erlang':%% Line 557 + '+' + (%% Line 557 + N, %% Line 557 + 1) + in %% Line 557 + apply 'count'/3 + (Rest, _92, Config) + %% Line 558 + <#{#<125>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_93> = + call %% Line 559 + 'erlang':%% Line 559 + '+' + (%% Line 559 + N, %% Line 559 + 1) + in %% Line 559 + apply 'count'/3 + (Rest, _93, Config) + %% Line 560 + <#{#<126>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_94> = + call %% Line 561 + 'erlang':%% Line 561 + '+' + (%% Line 561 + N, %% Line 561 + 1) + in %% Line 561 + apply 'count'/3 + (Rest, _94, Config) + %% Line 562 + <#{#<127>(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + let <_95> = + call %% Line 563 + 'erlang':%% Line 563 + '+' + (%% Line 563 + N, %% Line 563 + 1) + in %% Line 563 + apply 'count'/3 + (Rest, _95, Config) + %% Line 564 + <#{#<_173>('undefined','undefined','utf8',['unsigned'|['big']]), + #<_174>('all',8,'binary',['unsigned'|['big']])}#,N,{'config',_175,_176,_177,_178,_179,_180,_181,_182,_183,_184,_185,_186,'true',_187,_188,_189}> when 'true' -> + N + %% Line 565 + <#{#('undefined','undefined','utf8',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N,Config> when 'true' -> + %% Line 566 + case X of + %% Line 567 + <_190> + when call 'erlang':'<' + (X, + 2048) -> + let <_96> = + call 'erlang':'+' + (N, 2) + in apply 'count'/3 + (Rest, _96, Config) + %% Line 568 + <8232> when 'true' -> + N + %% Line 569 + <8233> when 'true' -> + N + %% Line 570 + <_193> + when call 'erlang':'<' + (X, + 65536) -> + let <_97> = + call 'erlang':'+' + (N, 3) + in apply 'count'/3 + (Rest, _97, Config) + %% Line 571 + <_196> when 'true' -> + let <_98> = + call 'erlang':'+' + (N, 4) + in apply 'count'/3 + (Rest, _98, Config) + end + %% Line 573 + <#{#<_197>(8,1,'integer',['unsigned'|['big']]), + #<_198>('all',8,'binary',['unsigned'|['big']])}#,N,_199> when 'true' -> + N + %% Line 574 + <#{}#,N,_200> when 'true' -> + N + ( <_102,_101,_100> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_102,_101,_100}) + -| [{'function_name',{'count',3}}] ) + -| ['compiler_generated'] ) + end +'strip_continuations'/2 = + %% Line 577 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + Bin + %% Line 578 + <#{#(8,1,'integer',['unsigned'|['big']]), + #('all',8,'binary',['unsigned'|['big']])}#,N> + when let <_2> = + call 'erlang':'>=' + (X, 128) + in let <_3> = + call 'erlang':'=<' + (X, 191) + in call 'erlang':'and' + (_2, _3) -> + let <_4> = + call %% Line 579 + 'erlang':%% Line 579 + '-' + (%% Line 579 + N, %% Line 579 + 1) + in %% Line 579 + apply 'strip_continuations'/2 + (Rest, _4) + %% Line 581 + when 'true' -> + Bin + end +'maybe_replace'/2 = + %% Line 584 + fun (_0,_1) -> + case <_0,_1> of + <8,{'config',_12,_13,'true',_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<98>(8,1,'integer',['unsigned'|['big']])}# + %% Line 585 + <9,{'config',_27,_28,'true',_29,_30,_31,_32,_33,_34,_35,_36,_37,_38,_39,_40,_41}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<116>(8,1,'integer',['unsigned'|['big']])}# + %% Line 586 + <10,{'config',_42,_43,'true',_44,_45,_46,_47,_48,_49,_50,_51,_52,_53,_54,_55,_56}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<110>(8,1,'integer',['unsigned'|['big']])}# + %% Line 587 + <12,{'config',_57,_58,'true',_59,_60,_61,_62,_63,_64,_65,_66,_67,_68,_69,_70,_71}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<102>(8,1,'integer',['unsigned'|['big']])}# + %% Line 588 + <13,{'config',_72,_73,'true',_74,_75,_76,_77,_78,_79,_80,_81,_82,_83,_84,_85,_86}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<114>(8,1,'integer',['unsigned'|['big']])}# + %% Line 589 + <34,{'config',_87,_88,'true',_89,_90,_91,_92,_93,_94,_95,_96,_97,_98,_99,_100,_101}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<34>(8,1,'integer',['unsigned'|['big']])}# + %% Line 590 + <47,Config = {'config',_102,_103,'true',_104,_105,_106,_107,_108,_109,_110,_111,_112,_113,_114,_115,_116}> when 'true' -> + %% Line 591 + ( case Config of + ( <( {'config',_117,_rec7,_118,_119,_120,_121,_122,_123,_124,_125,_126,_127,_128,_129,_130,_131} + -| ['compiler_generated'] )> when 'true' -> + case _rec7 of + %% Line 592 + <'true'> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<47>(8,1,'integer',['unsigned'|['big']])}# + %% Line 593 + <'false'> when 'true' -> + #{#<47>(8,1,'integer',['unsigned'|['big']])}# + ( <_4> when 'true' -> + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_132> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 595 + <92,{'config',_133,_134,'true',_135,_136,_137,_138,_139,_140,_141,_142,_143,_144,_145,_146,_147}> when 'true' -> + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<92>(8,1,'integer',['unsigned'|['big']])}# + %% Line 596 + + when call 'erlang':'<' + (X, + 32) -> + %% Line 597 + apply 'json_escape_sequence'/1 + (X) + %% Line 598 + + when let <_5> = + call 'erlang':'==' + (X, 8232) + in let <_6> = + call 'erlang':'==' + (X, 8233) + in call 'erlang':'or' + (_5, _6) -> + %% Line 599 + ( case Config of + ( <( {'config',_178,_179,_180,_181,_182,_183,_184,_185,_186,_187,_188,_189,_190,_rec8,_191,_192} + -| ['compiler_generated'] )> when 'true' -> + case _rec8 of + %% Line 600 + <'true'> when 'true' -> + #{#('undefined','undefined','utf8',['unsigned'|['big']])}# + %% Line 601 + <'false'> when 'true' -> + apply 'json_escape_sequence'/1 + (X) + ( <_9> when 'true' -> + primop 'match_fail' + ({'case_clause',_9}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_193> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 603 + + when call 'erlang':'is_atom' + (Atom) -> + %% Line 604 + call 'erlang':'error' + ('badarg') + %% Line 605 + <'surrogate',_X_Config> when 'true' -> + %% Line 606 + #{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<189>(8,1,'integer',['unsigned'|['big']])}# + %% Line 607 + <'badutf',_X_Config> when 'true' -> + %% Line 608 + #{#<239>(8,1,'integer',['unsigned'|['big']]), + #<191>(8,1,'integer',['unsigned'|['big']]), + #<189>(8,1,'integer',['unsigned'|['big']])}# + %% Line 609 + when 'true' -> + %% Line 610 + #{#('undefined','undefined','utf8',['unsigned'|['big']])}# + end +'json_escape_sequence'/1 = + %% Line 614 + fun (_0) -> + case _0 of + + when call 'erlang':'<' + (_0, + 65536) -> + %% Line 615 + case #{#(16,1,'integer',['unsigned'|['big']])}# of + <#{#(4,1,'integer',['unsigned'|['big']]), + #(4,1,'integer',['unsigned'|['big']]), + #(4,1,'integer',['unsigned'|['big']]), + #(4,1,'integer',['unsigned'|['big']])}#> when 'true' -> + let <_5> = + apply %% Line 616 + 'to_hex'/1 + (%% Line 616 + A) + in let <_4> = + apply %% Line 616 + 'to_hex'/1 + (%% Line 616 + B) + in let <_3> = + apply %% Line 616 + 'to_hex'/1 + (%% Line 616 + C) + in let <_2> = + apply %% Line 616 + 'to_hex'/1 + (%% Line 616 + D) + in %% Line 616 + #{#<92>(8,1,'integer',['unsigned'|['big']]), + #<117>(8,1,'integer',['unsigned'|['big']]), + #<_5>(8,1,'integer',['unsigned'|['big']]), + #<_4>(8,1,'integer',['unsigned'|['big']]), + #<_3>(8,1,'integer',['unsigned'|['big']]), + #<_2>(8,1,'integer',['unsigned'|['big']])}# + ( <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + -| ['compiler_generated'] ) + end + %% Line 617 + when 'true' -> + let = + call %% Line 618 + 'erlang':%% Line 618 + '-' + (%% Line 618 + X, %% Line 618 + 65536) + in %% Line 619 + case #{#(20,1,'integer',['unsigned'|['big']])}# of + <#{#(10,1,'integer',['unsigned'|['big']]), + #(10,1,'integer',['unsigned'|['big']])}#> when 'true' -> + let <_8> = + call %% Line 620 + 'erlang':%% Line 620 + '+' + (%% Line 620 + A, %% Line 620 + 55296) + in let <_9> = + apply %% Line 620 + 'json_escape_sequence'/1 + (_8) + in let <_10> = + call %% Line 620 + 'erlang':%% Line 620 + '+' + (%% Line 620 + B, %% Line 620 + 56320) + in let <_11> = + apply %% Line 620 + 'json_escape_sequence'/1 + (_10) + in %% Line 620 + [_9|[_11|[]]] + ( <_7> when 'true' -> + primop 'match_fail' + ({'badmatch',_7}) + -| ['compiler_generated'] ) + end + end +'to_hex'/1 = + %% Line 623 + fun (_0) -> + case _0 of + <10> when 'true' -> + 97 + %% Line 624 + <11> when 'true' -> + 98 + %% Line 625 + <12> when 'true' -> + 99 + %% Line 626 + <13> when 'true' -> + 100 + %% Line 627 + <14> when 'true' -> + 101 + %% Line 628 + <15> when 'true' -> + 102 + %% Line 629 + when 'true' -> + call 'erlang':'+' + (X, 48) + end +'init'/1 = + %% Line 635 + fun (_0) -> + case _0 of + <[]> when 'true' -> + [] + ( <_1> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_1}) + -| [{'function_name',{'init',1}}] ) + -| ['compiler_generated'] ) + end +'handle_event'/2 = + %% Line 640 + fun (_0,_1) -> + case <_0,_1> of + <'end_json',State> when 'true' -> + call 'lists':'reverse' + (State) + %% Line 641 + when 'true' -> + [Event|State] + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('jsx_parser') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('jsx_parser', _0) +end \ No newline at end of file diff --git a/test/data/jsx/jsx_parser.erl b/test/data/jsx/jsx_parser.erl new file mode 100644 index 0000000..070c934 --- /dev/null +++ b/test/data/jsx/jsx_parser.erl @@ -0,0 +1,1214 @@ +%% The MIT License + +%% Copyright (c) 2010-2013 Alisdair Sullivan + +%% Permission is hereby granted, free of charge, to any person obtaining a copy +%% of this software and associated documentation files (the "Software"), to deal +%% in the Software without restriction, including without limitation the rights +%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%% copies of the Software, and to permit persons to whom the Software is +%% furnished to do so, subject to the following conditions: + +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. + +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +%% THE SOFTWARE. + + +-module(jsx_parser). + +-export([parser/3, resume/5]). +-export([init/1, handle_event/2]). + + +-spec parser(Handler::module(), State::any(), Config::list()) -> jsx:parser(). + +parser(Handler, State, Config) -> + fun(Tokens) -> value(Tokens, {Handler, Handler:init(State)}, [], jsx_config:parse_config(Config)) end. + + +%% resume allows continuation from interrupted decoding without having to explicitly export +%% all states +-spec resume( + Rest::jsx:token(), + State::atom(), + Handler::module(), + Stack::list(atom()), + Config::jsx:config() + ) -> jsx:parser() | {incomplete, jsx:parser()}. + +resume(Rest, State, Handler, Stack, Config) -> + case State of + value -> value(Rest, Handler, Stack, Config); + object -> object(Rest, Handler, Stack, Config); + array -> array(Rest, Handler, Stack, Config); + maybe_done -> maybe_done(Rest, Handler, Stack, Config); + done -> done(Rest, Handler, Stack, Config) + end. + + +-include("jsx_config.hrl"). + + +%% error, incomplete and event macros +-ifndef(error). +-define(error(State, Terms, Handler, Stack, Config), + case Config#config.error_handler of + false -> erlang:error(badarg); + F -> F(Terms, {parser, State, Handler, Stack}, jsx_config:config_to_list(Config)) + end + +). +-endif. + + +incomplete(State, Handler, Stack, Config=#config{stream=false}) -> + ?error(State, [], Handler, Stack, Config); +incomplete(State, Handler, Stack, Config=#config{incomplete_handler=false}) -> + {incomplete, fun(End) when End == end_stream; End == end_json -> + case resume([end_json], State, Handler, Stack, Config) of + {incomplete, _} -> ?error(State, [], Handler, Stack, Config); + Else -> Else + end; + (Tokens) -> + resume(Tokens, State, Handler, Stack, Config) + end + }; +incomplete(State, Handler, Stack, Config=#config{incomplete_handler=F}) -> + F([], {parser, State, Handler, Stack}, jsx_config:config_to_list(Config)). + + +handle_event(Event, {Handler, State}, _Config) -> {Handler, Handler:handle_event(Event, State)}. + + +value([String|Tokens], Handler, Stack, Config) when is_binary(String) -> + try clean_string(String, Config) of Clean -> + maybe_done(Tokens, handle_event({string, Clean}, Handler, Config), Stack, Config) + catch error:badarg -> + ?error(value, [{string, String}|Tokens], Handler, Stack, Config) + end; +value([true|Tokens], Handler, Stack, Config) -> + maybe_done(Tokens, handle_event({literal, true}, Handler, Config), Stack, Config); +value([false|Tokens], Handler, Stack, Config) -> + maybe_done(Tokens, handle_event({literal, false}, Handler, Config), Stack, Config); +value([null|Tokens], Handler, Stack, Config) -> + maybe_done(Tokens, handle_event({literal, null}, Handler, Config), Stack, Config); +value([start_object|Tokens], Handler, Stack, Config) -> + object(Tokens, handle_event(start_object, Handler, Config), [object|Stack], Config); +value([start_array|Tokens], Handler, Stack, Config) -> + array(Tokens, handle_event(start_array, Handler, Config), [array|Stack], Config); +value([Number|Tokens], Handler, Stack, Config) when is_integer(Number) -> + maybe_done(Tokens, handle_event({integer, Number}, Handler, Config), Stack, Config); +value([Number|Tokens], Handler, Stack, Config) when is_float(Number) -> + maybe_done(Tokens, handle_event({float, Number}, Handler, Config), Stack, Config); +value([{raw, Raw}|Tokens], Handler, Stack, Config) when is_binary(Raw) -> + value((jsx:decoder(?MODULE, [], []))(Raw) ++ Tokens, Handler, Stack, Config); +value([{_,_,_}=Timestamp|Tokens], Handler, Stack, Config) -> + {{Year, Month, Day}, {Hour, Min, Sec}} = calendar:now_to_datetime( + Timestamp), + value([{string, unicode:characters_to_binary(io_lib:format( + "~4.10.0B-~2.10.0B-~2.10.0BT~2.10.0B:~2.10.0B:~2.10.0BZ", + [Year, Month, Day, Hour, Min, Sec] + ))}|Tokens], + Handler, + Stack, + Config + ); +value([{{Year, Month, Day}, {Hour, Min, Sec}}|Tokens], Handler, Stack, Config) +when is_integer(Year), is_integer(Month), is_integer(Day), is_integer(Hour), is_integer(Min), is_integer(Sec) -> + value([{string, unicode:characters_to_binary(io_lib:format( + "~4.10.0B-~2.10.0B-~2.10.0BT~2.10.0B:~2.10.0B:~2.10.0BZ", + [Year, Month, Day, Hour, Min, Sec] + ))}|Tokens], + Handler, + Stack, + Config + ); +value([{{Year, Month, Day}, {Hour, Min, Sec}}|Tokens], Handler, Stack, Config) +when is_integer(Year), is_integer(Month), is_integer(Day), is_integer(Hour), is_integer(Min), is_float(Sec) -> + value([{string, unicode:characters_to_binary(io_lib:format( + "~4.10.0B-~2.10.0B-~2.10.0BT~2.10.0B:~2.10.0B:~9.6.0fZ", + [Year, Month, Day, Hour, Min, Sec] + ))}|Tokens], + Handler, + Stack, + Config + ); +value([{literal, Value}|Tokens], Handler, Stack, Config) +when Value == true; Value == false; Value == null -> + value([Value] ++ Tokens, Handler, Stack, Config); +value([{integer, Value}|Tokens], Handler, Stack, Config) +when is_integer(Value) -> + value([Value] ++ Tokens, Handler, Stack, Config); +value([{float, Value}|Tokens], Handler, Stack, Config) +when is_float(Value) -> + value([Value] ++ Tokens, Handler, Stack, Config); +value([{string, Value}|Tokens], Handler, Stack, Config) +when is_binary(Value); is_atom(Value) -> + value([Value] ++ Tokens, Handler, Stack, Config); +value([{number, Value}|Tokens], Handler, Stack, Config) +when is_float(Value); is_integer(Value) -> + value([Value] ++ Tokens, Handler, Stack, Config); +value([String|Tokens], Handler, Stack, Config) when is_atom(String) -> + value([{string, atom_to_binary(String, utf8)}] ++ Tokens, Handler, Stack, Config); +value([], Handler, Stack, Config) -> + incomplete(value, Handler, Stack, Config); +value(BadTokens, Handler, Stack, Config) when is_list(BadTokens) -> + ?error(value, BadTokens, Handler, Stack, Config); +value(Token, Handler, Stack, Config) -> + value([Token], Handler, Stack, Config). + + +object([end_object|Tokens], Handler, [object|Stack], Config) -> + maybe_done(Tokens, handle_event(end_object, Handler, Config), Stack, Config); +object([{key, Key}|Tokens], Handler, Stack, Config) +when is_atom(Key); is_binary(Key); is_integer(Key) -> + object([Key|Tokens], Handler, Stack, Config); +object([Key|Tokens], Handler, [object|Stack], Config) +when is_atom(Key); is_binary(Key); is_integer(Key) -> + try clean_string(fix_key(Key), Config) + of K -> + value( + Tokens, + handle_event({key, K}, Handler, Config), + [object|Stack], + Config + ) + catch error:badarg -> + ?error(object, [{string, Key}|Tokens], Handler, Stack, Config) + end; +object([], Handler, Stack, Config) -> + incomplete(object, Handler, Stack, Config); +object(Token, Handler, Stack, Config) -> + object([Token], Handler, Stack, Config). + + +array([end_array|Tokens], Handler, [array|Stack], Config) -> + maybe_done(Tokens, handle_event(end_array, Handler, Config), Stack, Config); +array([], Handler, Stack, Config) -> + incomplete(array, Handler, Stack, Config); +array(Tokens, Handler, Stack, Config) when is_list(Tokens) -> + value(Tokens, Handler, Stack, Config); +array(Token, Handler, Stack, Config) -> + array([Token], Handler, Stack, Config). + + +maybe_done([end_json], Handler, [], Config) -> + done([end_json], Handler, [], Config); +maybe_done(Tokens, Handler, [object|_] = Stack, Config) when is_list(Tokens) -> + object(Tokens, Handler, Stack, Config); +maybe_done(Tokens, Handler, [array|_] = Stack, Config) when is_list(Tokens) -> + array(Tokens, Handler, Stack, Config); +maybe_done([], Handler, Stack, Config) -> + incomplete(maybe_done, Handler, Stack, Config); +maybe_done(BadTokens, Handler, Stack, Config) when is_list(BadTokens) -> + ?error(maybe_done, BadTokens, Handler, Stack, Config); +maybe_done(Token, Handler, Stack, Config) -> + maybe_done([Token], Handler, Stack, Config). + + +done([], Handler, [], Config=#config{stream=true}) -> + incomplete(done, Handler, [], Config); +done(Tokens, Handler, [], Config) when Tokens == [end_json]; Tokens == [] -> + {_, State} = handle_event(end_json, Handler, Config), + State; +done(BadTokens, Handler, Stack, Config) when is_list(BadTokens) -> + ?error(done, BadTokens, Handler, Stack, Config); +done(Token, Handler, Stack, Config) -> + done([Token], Handler, Stack, Config). + + +fix_key(Key) when is_atom(Key) -> atom_to_binary(Key, utf8); +fix_key(Key) when is_integer(Key) -> list_to_binary(integer_to_list(Key)); +fix_key(Key) when is_binary(Key) -> Key. + + +clean_string(Bin, #config{dirty_strings=true}) -> Bin; +clean_string(Bin, Config) -> clean(Bin, [], Config). + + +%% unroll the control characters +clean(<<0, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(0, Config)], Config); +clean(<<1, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(1, Config)], Config); +clean(<<2, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(2, Config)], Config); +clean(<<3, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(3, Config)], Config); +clean(<<4, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(4, Config)], Config); +clean(<<5, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(5, Config)], Config); +clean(<<6, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(6, Config)], Config); +clean(<<7, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(7, Config)], Config); +clean(<<8, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(8, Config)], Config); +clean(<<9, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(9, Config)], Config); +clean(<<10, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(10, Config)], Config); +clean(<<11, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(11, Config)], Config); +clean(<<12, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(12, Config)], Config); +clean(<<13, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(13, Config)], Config); +clean(<<14, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(14, Config)], Config); +clean(<<15, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(15, Config)], Config); +clean(<<16, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(16, Config)], Config); +clean(<<17, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(17, Config)], Config); +clean(<<18, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(18, Config)], Config); +clean(<<19, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(19, Config)], Config); +clean(<<20, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(20, Config)], Config); +clean(<<21, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(21, Config)], Config); +clean(<<22, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(22, Config)], Config); +clean(<<23, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(23, Config)], Config); +clean(<<24, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(24, Config)], Config); +clean(<<25, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(25, Config)], Config); +clean(<<26, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(26, Config)], Config); +clean(<<27, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(27, Config)], Config); +clean(<<28, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(28, Config)], Config); +clean(<<29, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(29, Config)], Config); +clean(<<30, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(30, Config)], Config); +clean(<<31, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(31, Config)], Config); +clean(<<34, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(34, Config)], Config); +clean(<<47, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(47, Config)], Config); +clean(<<92, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(92, Config)], Config); +clean(<> = Bin, Acc, Config=#config{uescape=true}) -> + case X of + X when X < 16#80 -> start_count(Bin, Acc, Config); + _ -> clean(Rest, [Acc, json_escape_sequence(X)], Config) + end; +%% u+2028 +clean(<<226, 128, 168, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(16#2028, Config)], Config); +%% u+2029 +clean(<<226, 128, 169, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(16#2029, Config)], Config); +clean(<<_/utf8, _/binary>> = Bin, Acc, Config) -> start_count(Bin, Acc, Config); +%% surrogates +clean(<<237, X, _, Rest/binary>>, Acc, Config) when X >= 160 -> + clean(Rest, [Acc, maybe_replace(surrogate, Config)], Config); +%% overlong encodings and missing continuations of a 2 byte sequence +clean(<>, Acc, Config) when X >= 192, X =< 223 -> + clean(strip_continuations(Rest, 1), [Acc, maybe_replace(badutf, Config)], Config); +%% overlong encodings and missing continuations of a 3 byte sequence +clean(<>, Acc, Config) when X >= 224, X =< 239 -> + clean(strip_continuations(Rest, 2), [Acc, maybe_replace(badutf, Config)], Config); +%% overlong encodings and missing continuations of a 4 byte sequence +clean(<>, Acc, Config) when X >= 240, X =< 247 -> + clean(strip_continuations(Rest, 3), [Acc, maybe_replace(badutf, Config)], Config); +clean(<<_, Rest/binary>>, Acc, Config) -> + clean(Rest, [Acc, maybe_replace(badutf, Config)], Config); +clean(<<>>, Acc, _) -> iolist_to_binary(Acc). + + +start_count(Bin, Acc, Config) -> + Size = count(Bin, 0, Config), + <> = Bin, + clean(Rest, [Acc, Clean], Config). + + +%% again, unrolling ascii makes a huge difference. sadly +count(<<0, _/binary>>, N, _) -> N; +count(<<1, _/binary>>, N, _) -> N; +count(<<2, _/binary>>, N, _) -> N; +count(<<3, _/binary>>, N, _) -> N; +count(<<4, _/binary>>, N, _) -> N; +count(<<5, _/binary>>, N, _) -> N; +count(<<6, _/binary>>, N, _) -> N; +count(<<7, _/binary>>, N, _) -> N; +count(<<8, _/binary>>, N, _) -> N; +count(<<9, _/binary>>, N, _) -> N; +count(<<10, _/binary>>, N, _) -> N; +count(<<11, _/binary>>, N, _) -> N; +count(<<12, _/binary>>, N, _) -> N; +count(<<13, _/binary>>, N, _) -> N; +count(<<14, _/binary>>, N, _) -> N; +count(<<15, _/binary>>, N, _) -> N; +count(<<16, _/binary>>, N, _) -> N; +count(<<17, _/binary>>, N, _) -> N; +count(<<18, _/binary>>, N, _) -> N; +count(<<19, _/binary>>, N, _) -> N; +count(<<20, _/binary>>, N, _) -> N; +count(<<21, _/binary>>, N, _) -> N; +count(<<22, _/binary>>, N, _) -> N; +count(<<23, _/binary>>, N, _) -> N; +count(<<24, _/binary>>, N, _) -> N; +count(<<25, _/binary>>, N, _) -> N; +count(<<26, _/binary>>, N, _) -> N; +count(<<27, _/binary>>, N, _) -> N; +count(<<28, _/binary>>, N, _) -> N; +count(<<29, _/binary>>, N, _) -> N; +count(<<30, _/binary>>, N, _) -> N; +count(<<31, _/binary>>, N, _) -> N; +count(<<32, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<33, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<34, _/binary>>, N, _) -> N; +count(<<35, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<36, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<37, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<38, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<39, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<40, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<41, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<42, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<43, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<44, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<45, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<46, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<47, _/binary>>, N, _) -> N; +count(<<48, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<49, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<50, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<51, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<52, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<53, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<54, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<55, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<56, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<57, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<58, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<59, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<60, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<61, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<62, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<63, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<64, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<65, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<66, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<67, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<68, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<69, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<70, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<71, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<72, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<73, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<74, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<75, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<76, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<77, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<78, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<79, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<80, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<81, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<82, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<83, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<84, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<85, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<86, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<87, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<88, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<89, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<90, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<91, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<92, _/binary>>, N, _) -> N; +count(<<93, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<94, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<95, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<96, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<97, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<98, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<99, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<100, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<101, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<102, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<103, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<104, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<105, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<106, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<107, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<108, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<109, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<110, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<111, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<112, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<113, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<114, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<115, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<116, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<117, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<118, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<119, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<120, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<121, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<122, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<123, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<124, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<125, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<126, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<127, Rest/binary>>, N, Config) -> + count(Rest, N + 1, Config); +count(<<_/utf8, _/binary>>, N, #config{uescape=true}) -> N; +count(<>, N, Config) -> + case X of + X when X < 16#800 -> count(Rest, N + 2, Config); + 16#2028 -> N; + 16#2029 -> N; + X when X < 16#10000 -> count(Rest, N + 3, Config); + _ -> count(Rest, N + 4, Config) + end; +count(<<_, _/binary>>, N, _) -> N; +count(<<>>, N, _) -> N. + + +strip_continuations(Bin, 0) -> Bin; +strip_continuations(<>, N) when X >= 128, X =< 191 -> + strip_continuations(Rest, N - 1); +%% not a continuation byte +strip_continuations(Bin, _) -> Bin. + + +maybe_replace($\b, #config{escaped_strings=true}) -> <<$\\, $b>>; +maybe_replace($\t, #config{escaped_strings=true}) -> <<$\\, $t>>; +maybe_replace($\n, #config{escaped_strings=true}) -> <<$\\, $n>>; +maybe_replace($\f, #config{escaped_strings=true}) -> <<$\\, $f>>; +maybe_replace($\r, #config{escaped_strings=true}) -> <<$\\, $r>>; +maybe_replace($\", #config{escaped_strings=true}) -> <<$\\, $\">>; +maybe_replace($/, Config=#config{escaped_strings=true}) -> + case Config#config.escaped_forward_slashes of + true -> <<$\\, $/>>; + false -> <<$/>> + end; +maybe_replace($\\, #config{escaped_strings=true}) -> <<$\\, $\\>>; +maybe_replace(X, #config{escaped_strings=true}) when X < 32 -> + json_escape_sequence(X); +maybe_replace(X, Config=#config{escaped_strings=true}) when X == 16#2028; X == 16#2029 -> + case Config#config.unescaped_jsonp of + true -> <>; + false -> json_escape_sequence(X) + end; +maybe_replace(Atom, #config{strict_utf8=true}) when is_atom(Atom) -> + erlang:error(badarg); +maybe_replace(surrogate, _Config) -> + <<16#fffd/utf8>>; +maybe_replace(badutf, _Config) -> + <<16#fffd/utf8>>; +maybe_replace(X, _Config) -> + <>. + + +%% convert a codepoint to it's \uXXXX equiv. +json_escape_sequence(X) when X < 65536 -> + <> = <>, + <<$\\, $u, (to_hex(A)), (to_hex(B)), (to_hex(C)), (to_hex(D))>>; +json_escape_sequence(X) -> + Adjusted = X - 16#10000, + <> = <>, + [json_escape_sequence(A + 16#d800), json_escape_sequence(B + 16#dc00)]. + + +to_hex(10) -> $a; +to_hex(11) -> $b; +to_hex(12) -> $c; +to_hex(13) -> $d; +to_hex(14) -> $e; +to_hex(15) -> $f; +to_hex(X) -> X + 48. %% ascii "1" is [49], "2" is [50], etc... + + +%% for raw input +-spec init(proplists:proplist()) -> list(). + +init([]) -> []. + + +-spec handle_event(Event::any(), Acc::list()) -> list(). + +handle_event(end_json, State) -> lists:reverse(State); +handle_event(Event, State) -> [Event] ++ State. + + + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + + +parse(Events, Config) -> value(Events, {jsx, []}, [], jsx_config:parse_config(Config)). + + +error_test_() -> + [ + {"value error", ?_assertError(badarg, parse([self()], []))}, + {"maybe_done error", ?_assertError(badarg, parse([start_array, end_array, start_array, end_json], []))}, + {"done error", ?_assertError(badarg, parse([{string, <<"">>}, {literal, true}, end_json], []))}, + {"string error", ?_assertError(badarg, parse([{string, <<237, 160, 128>>}, end_json], [strict]))} + ]. + + +custom_error_handler_test_() -> + Error = fun(Rest, {_, State, _, _}, _) -> {State, Rest} end, + [ + {"value error", ?_assertEqual( + {value, [self()]}, + parse([self()], [{error_handler, Error}]) + )}, + {"maybe_done error", ?_assertEqual( + {maybe_done, [start_array, end_json]}, + parse([start_array, end_array, start_array, end_json], [{error_handler, Error}]) + )}, + {"done error", ?_assertEqual( + {maybe_done, [{literal, true}, end_json]}, + parse([{string, <<"">>}, {literal, true}, end_json], [{error_handler, Error}]) + )}, + {"string error", ?_assertEqual( + {value, [{string, <<237, 160, 128>>}, end_json]}, + parse([{string, <<237, 160, 128>>}, end_json], [{error_handler, Error}, strict]) + )} + ]. + + +incomplete_test_() -> + Cases = [ + {"incomplete value", []}, + {"incomplete object", [start_object]}, + {"incomplete array", [start_array]}, + {"incomplete maybe_done", [start_array, end_array]} + ], + [{Title, ?_assertError(badarg, parse(Events, []))} + || {Title, Events} <- Cases + ]. + + +custom_incomplete_handler_test_() -> + [ + {"custom incomplete handler", ?_assertError( + badarg, + parse([], [{incomplete_handler, fun(_, _, _) -> erlang:error(badarg) end}]) + )} + ]. + + +raw_test_() -> + Parse = fun(Events, Config) -> (parser(?MODULE, [], Config))(Events ++ [end_json]) end, + [ + {"raw empty list", ?_assertEqual( + [start_array, end_array], + Parse([{raw, <<"[]">>}], []) + )}, + {"raw empty object", ?_assertEqual( + [start_object, end_object], + Parse([{raw, <<"{}">>}], []) + )}, + {"raw chunk inside stream", ?_assertEqual( + [start_object, {key, <<"key">>}, start_array, {literal, true}, end_array, end_object], + Parse([start_object, {key, <<"key">>}, {raw, <<"[true]">>}, end_object], []) + )} + ]. + + +%% erlang refuses to encode certain codepoints, so fake them +to_fake_utf8(N) when N < 16#0080 -> <>; +to_fake_utf8(N) when N < 16#0800 -> + <<0:5, Y:5, X:6>> = <>, + <<2#110:3, Y:5, 2#10:2, X:6>>; +to_fake_utf8(N) when N < 16#10000 -> + <> = <>, + <<2#1110:4, Z:4, 2#10:2, Y:6, 2#10:2, X:6>>; +to_fake_utf8(N) -> + <<0:3, W:3, Z:6, Y:6, X:6>> = <>, + <<2#11110:5, W:3, 2#10:2, Z:6, 2#10:2, Y:6, 2#10:2, X:6>>. + + +codepoints() -> + unicode:characters_to_binary( + [32, 33] + ++ lists:seq(35, 46) + ++ lists:seq(48, 91) + ++ lists:seq(93, 16#2027) + ++ lists:seq(16#202a, 16#d7ff) + ++ lists:seq(16#e000, 16#ffff) + ). + + +extended_codepoints() -> + unicode:characters_to_binary( + lists:seq(16#10000, 16#1ffff) ++ [ + 16#20000, 16#30000, 16#40000, 16#50000, 16#60000, + 16#70000, 16#80000, 16#90000, 16#a0000, 16#b0000, + 16#c0000, 16#d0000, 16#e0000, 16#f0000, 16#100000 + ] + ). + + +surrogates() -> [ to_fake_utf8(N) || N <- lists:seq(16#d800, 16#dfff) ]. + + +clean_string_helper(String) -> + try clean_string(String, #config{strict_utf8=true}) of Clean -> Clean + catch error:badarg -> {error, badarg} + end. + + +clean_string_test_() -> + [ + {"clean codepoints", ?_assertEqual( + codepoints(), + clean_string(codepoints(), #config{}) + )}, + {"clean extended codepoints", ?_assertEqual( + extended_codepoints(), + clean_string(extended_codepoints(), #config{}) + )}, + {"escape path codepoints", ?_assertEqual( + codepoints(), + clean_string(codepoints(), #config{escaped_strings=true}) + )}, + {"escape path extended codepoints", ?_assertEqual( + extended_codepoints(), + clean_string(extended_codepoints(), #config{escaped_strings=true}) + )}, + {"error surrogates", ?_assertEqual( + lists:duplicate(length(surrogates()), {error, badarg}), + lists:map(fun(Codepoint) -> clean_string_helper(Codepoint) end, surrogates()) + )}, + {"clean surrogates", ?_assertEqual( + lists:duplicate(length(surrogates()), <<16#fffd/utf8>>), + lists:map(fun(Codepoint) -> clean_string(Codepoint, #config{}) end, surrogates()) + )} + ]. + + +escape_test_() -> + [ + {"maybe_escape backspace", ?_assertEqual( + <<"\\b">>, + clean_string(<<16#0008/utf8>>, #config{escaped_strings=true}) + )}, + {"don't escape backspace", ?_assertEqual( + <<"\b">>, + clean_string(<<16#0008/utf8>>, #config{}) + )}, + {"maybe_escape tab", ?_assertEqual( + <<"\\t">>, + clean_string(<<16#0009/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape newline", ?_assertEqual( + <<"\\n">>, + clean_string(<<16#000a/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape formfeed", ?_assertEqual( + <<"\\f">>, + clean_string(<<16#000c/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape carriage return", ?_assertEqual( + <<"\\r">>, + clean_string(<<16#000d/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape quote", ?_assertEqual( + <<"\\\"">>, + clean_string(<<16#0022/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape forward slash", ?_assertEqual( + <<"\\/">>, + clean_string(<<16#002f/utf8>>, #config{escaped_strings=true, escaped_forward_slashes=true}) + )}, + {"do not maybe_escape forward slash", ?_assertEqual( + <<"/">>, + clean_string(<<16#002f/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape backslash", ?_assertEqual( + <<"\\\\">>, + clean_string(<<16#005c/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape jsonp (u2028)", ?_assertEqual( + <<"\\u2028">>, + clean_string(<<16#2028/utf8>>, #config{escaped_strings=true}) + )}, + {"do not maybe_escape jsonp (u2028)", ?_assertEqual( + <<16#2028/utf8>>, + clean_string(<<16#2028/utf8>>, #config{escaped_strings=true, unescaped_jsonp=true}) + )}, + {"maybe_escape jsonp (u2029)", ?_assertEqual( + <<"\\u2029">>, + clean_string(<<16#2029/utf8>>, #config{escaped_strings=true}) + )}, + {"do not maybe_escape jsonp (u2029)", ?_assertEqual( + <<16#2029/utf8>>, + clean_string(<<16#2029/utf8>>, #config{escaped_strings=true, unescaped_jsonp=true}) + )}, + {"maybe_escape u0000", ?_assertEqual( + <<"\\u0000">>, + clean_string(<<16#0000/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0001", ?_assertEqual( + <<"\\u0001">>, + clean_string(<<16#0001/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0002", ?_assertEqual( + <<"\\u0002">>, + clean_string(<<16#0002/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0003", ?_assertEqual( + <<"\\u0003">>, + clean_string(<<16#0003/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0004", ?_assertEqual( + <<"\\u0004">>, + clean_string(<<16#0004/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0005", ?_assertEqual( + <<"\\u0005">>, + clean_string(<<16#0005/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0006", ?_assertEqual( + <<"\\u0006">>, + clean_string(<<16#0006/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0007", ?_assertEqual( + <<"\\u0007">>, + clean_string(<<16#0007/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u000b", ?_assertEqual( + <<"\\u000b">>, + clean_string(<<16#000b/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u000e", ?_assertEqual( + <<"\\u000e">>, + clean_string(<<16#000e/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u000f", ?_assertEqual( + <<"\\u000f">>, + clean_string(<<16#000f/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0010", ?_assertEqual( + <<"\\u0010">>, + clean_string(<<16#0010/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0011", ?_assertEqual( + <<"\\u0011">>, + clean_string(<<16#0011/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0012", ?_assertEqual( + <<"\\u0012">>, + clean_string(<<16#0012/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0013", ?_assertEqual( + <<"\\u0013">>, + clean_string(<<16#0013/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0014", ?_assertEqual( + <<"\\u0014">>, + clean_string(<<16#0014/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0015", ?_assertEqual( + <<"\\u0015">>, + clean_string(<<16#0015/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0016", ?_assertEqual( + <<"\\u0016">>, + clean_string(<<16#0016/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0017", ?_assertEqual( + <<"\\u0017">>, + clean_string(<<16#0017/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0018", ?_assertEqual( + <<"\\u0018">>, + clean_string(<<16#0018/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u0019", ?_assertEqual( + <<"\\u0019">>, + clean_string(<<16#0019/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u001a", ?_assertEqual( + <<"\\u001a">>, + clean_string(<<16#001a/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u001b", ?_assertEqual( + <<"\\u001b">>, + clean_string(<<16#001b/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u001c", ?_assertEqual( + <<"\\u001c">>, + clean_string(<<16#001c/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u001d", ?_assertEqual( + <<"\\u001d">>, + clean_string(<<16#001d/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u001e", ?_assertEqual( + <<"\\u001e">>, + clean_string(<<16#001e/utf8>>, #config{escaped_strings=true}) + )}, + {"maybe_escape u001f", ?_assertEqual( + <<"\\u001f">>, + clean_string(<<16#001f/utf8>>, #config{escaped_strings=true}) + )} + ]. + + +bad_utf8_test_() -> + [ + {"orphan continuation byte u+0080", ?_assertError( + badarg, + clean_string(<<16#0080>>, #config{strict_utf8=true}) + )}, + {"orphan continuation byte u+0080 replaced", ?_assertEqual( + <<16#fffd/utf8>>, + clean_string(<<16#0080>>, #config{}) + )}, + {"orphan continuation byte u+00bf", ?_assertError( + badarg, + clean_string(<<16#00bf>>, #config{strict_utf8=true}) + )}, + {"orphan continuation byte u+00bf replaced", ?_assertEqual( + <<16#fffd/utf8>>, + clean_string(<<16#00bf>>, #config{}) + )}, + {"2 continuation bytes", ?_assertError( + badarg, + clean_string(<<(binary:copy(<<16#0080>>, 2))/binary>>, #config{strict_utf8=true}) + )}, + {"2 continuation bytes replaced", ?_assertEqual( + binary:copy(<<16#fffd/utf8>>, 2), + clean_string(<<(binary:copy(<<16#0080>>, 2))/binary>>, #config{}) + )}, + {"3 continuation bytes", ?_assertError( + badarg, + clean_string(<<(binary:copy(<<16#0080>>, 3))/binary>>, #config{strict_utf8=true}) + )}, + {"3 continuation bytes replaced", ?_assertEqual( + binary:copy(<<16#fffd/utf8>>, 3), + clean_string(<<(binary:copy(<<16#0080>>, 3))/binary>>, #config{}) + )}, + {"4 continuation bytes", ?_assertError( + badarg, + clean_string(<<(binary:copy(<<16#0080>>, 4))/binary>>, #config{strict_utf8=true}) + )}, + {"4 continuation bytes replaced", ?_assertEqual( + binary:copy(<<16#fffd/utf8>>, 4), + clean_string(<<(binary:copy(<<16#0080>>, 4))/binary>>, #config{}) + )}, + {"5 continuation bytes", ?_assertError( + badarg, + clean_string(<<(binary:copy(<<16#0080>>, 5))/binary>>, #config{strict_utf8=true}) + )}, + {"5 continuation bytes replaced", ?_assertEqual( + binary:copy(<<16#fffd/utf8>>, 5), + clean_string(<<(binary:copy(<<16#0080>>, 5))/binary>>, #config{}) + )}, + {"6 continuation bytes", ?_assertError( + badarg, + clean_string(<<(binary:copy(<<16#0080>>, 6))/binary>>, #config{strict_utf8=true}) + )}, + {"6 continuation bytes replaced", ?_assertEqual( + binary:copy(<<16#fffd/utf8>>, 6), + clean_string(<<(binary:copy(<<16#0080>>, 6))/binary>>, #config{}) + )}, + {"all continuation bytes", ?_assertError( + badarg, + clean_string(<<(list_to_binary(lists:seq(16#0080, 16#00bf)))/binary>>, #config{strict_utf8=true}) + )}, + {"all continuation bytes replaced", ?_assertEqual( + binary:copy(<<16#fffd/utf8>>, length(lists:seq(16#0080, 16#00bf))), + clean_string( + <<(list_to_binary(lists:seq(16#0080, 16#00bf)))/binary>>, + #config{} + ) + )}, + {"lonely start byte", ?_assertError( + badarg, + clean_string(<<16#00c0>>, #config{strict_utf8=true}) + )}, + {"lonely start byte replaced", ?_assertEqual( + <<16#fffd/utf8>>, + clean_string(<<16#00c0>>, #config{}) + )}, + {"lonely start bytes (2 byte)", ?_assertError( + badarg, + clean_string(<<16#00c0, 32, 16#00df>>, #config{strict_utf8=true}) + )}, + {"lonely start bytes (2 byte) replaced", ?_assertEqual( + <<16#fffd/utf8, 32, 16#fffd/utf8>>, + clean_string(<<16#00c0, 32, 16#00df>>, #config{}) + )}, + {"lonely start bytes (3 byte)", ?_assertError( + badarg, + clean_string(<<16#00e0, 32, 16#00ef>>, #config{strict_utf8=true}) + )}, + {"lonely start bytes (3 byte) replaced", ?_assertEqual( + <<16#fffd/utf8, 32, 16#fffd/utf8>>, + clean_string(<<16#00e0, 32, 16#00ef>>, #config{}) + )}, + {"lonely start bytes (4 byte)", ?_assertError( + badarg, + clean_string(<<16#00f0, 32, 16#00f7>>, #config{strict_utf8=true}) + )}, + {"lonely start bytes (4 byte) replaced", ?_assertEqual( + <<16#fffd/utf8, 32, 16#fffd/utf8>>, + clean_string(<<16#00f0, 32, 16#00f7>>, #config{}) + )}, + {"missing continuation byte (3 byte)", ?_assertError( + badarg, + clean_string(<<224, 160, 32>>, #config{strict_utf8=true}) + )}, + {"missing continuation byte (3 byte) replaced", ?_assertEqual( + <<16#fffd/utf8, 32>>, + clean_string(<<224, 160, 32>>, #config{}) + )}, + {"missing continuation byte (4 byte missing one)", ?_assertError( + badarg, + clean_string(<<240, 144, 128, 32>>, #config{strict_utf8=true}) + )}, + {"missing continuation byte (4 byte missing one) replaced", ?_assertEqual( + <<16#fffd/utf8, 32>>, + clean_string(<<240, 144, 128, 32>>, #config{}) + )}, + {"missing continuation byte (4 byte missing two)", ?_assertError( + badarg, + clean_string(<<240, 144, 32>>, #config{strict_utf8=true}) + )}, + {"missing continuation byte (4 byte missing two) replaced", ?_assertEqual( + <<16#fffd/utf8, 32>>, + clean_string(<<240, 144, 32>>, #config{}) + )}, + {"overlong encoding of u+002f (2 byte)", ?_assertError( + badarg, + clean_string(<<16#c0, 16#af, 32>>, #config{strict_utf8=true}) + )}, + {"overlong encoding of u+002f (2 byte) replaced", ?_assertEqual( + <<16#fffd/utf8, 32>>, + clean_string(<<16#c0, 16#af, 32>>, #config{}) + )}, + {"overlong encoding of u+002f (3 byte)", ?_assertError( + badarg, + clean_string(<<16#e0, 16#80, 16#af, 32>>, #config{strict_utf8=true}) + )}, + {"overlong encoding of u+002f (3 byte) replaced", ?_assertEqual( + <<16#fffd/utf8, 32>>, + clean_string(<<16#e0, 16#80, 16#af, 32>>, #config{}) + )}, + {"overlong encoding of u+002f (4 byte)", ?_assertError( + badarg, + clean_string(<<16#f0, 16#80, 16#80, 16#af, 32>>, #config{strict_utf8=true}) + )}, + {"overlong encoding of u+002f (4 byte) replaced", ?_assertEqual( + <<16#fffd/utf8, 32>>, + clean_string(<<16#f0, 16#80, 16#80, 16#af, 32>>, #config{}) + )}, + {"highest overlong 2 byte sequence", ?_assertError( + badarg, + clean_string(<<16#c1, 16#bf, 32>>, #config{strict_utf8=true}) + )}, + {"highest overlong 2 byte sequence replaced", ?_assertEqual( + <<16#fffd/utf8, 32>>, + clean_string(<<16#c1, 16#bf, 32>>, #config{}) + )}, + {"highest overlong 3 byte sequence", ?_assertError( + badarg, + clean_string(<<16#e0, 16#9f, 16#bf, 32>>, #config{strict_utf8=true}) + )}, + {"highest overlong 3 byte sequence replaced", ?_assertEqual( + <<16#fffd/utf8, 32>>, + clean_string(<<16#e0, 16#9f, 16#bf, 32>>, #config{}) + )}, + {"highest overlong 4 byte sequence", ?_assertError( + badarg, + clean_string(<<16#f0, 16#8f, 16#bf, 16#bf, 32>>, #config{strict_utf8=true}) + )}, + {"highest overlong 4 byte sequence replaced", ?_assertEqual( + <<16#fffd/utf8, 32>>, + clean_string(<<16#f0, 16#8f, 16#bf, 16#bf, 32>>, #config{}) + )} + ]. + + +json_escape_sequence_test_() -> + [ + {"json escape sequence test - 16#0000", ?_assertEqual(<<"\\u0000"/utf8>>, json_escape_sequence(16#0000))}, + {"json escape sequence test - 16#abc", ?_assertEqual(<<"\\u0abc"/utf8>>, json_escape_sequence(16#abc))}, + {"json escape sequence test - 16#def", ?_assertEqual(<<"\\u0def"/utf8>>, json_escape_sequence(16#def))} + ]. + + +uescape_test_() -> + [ + {"\"\\u0080\"", ?_assertEqual( + <<"\\u0080">>, + clean_string(<<128/utf8>>, #config{uescape=true}) + )}, + {"\"\\u8ca8\\u5481\\u3002\\u0091\\u0091\"", ?_assertEqual( + <<"\\u8ca8\\u5481\\u3002\\u0091\\u0091">>, + clean_string( + <<232,178,168,229,146,129,227,128,130,194,145,194,145>>, + #config{uescape=true} + ) + )}, + {"\"\\ud834\\udd1e\"", ?_assertEqual( + <<"\\ud834\\udd1e">>, + clean_string(<<240, 157, 132, 158>>, #config{uescape=true}) + )}, + {"\"\\ud83d\\ude0a\"", ?_assertEqual( + <<"\\ud83d\\ude0a">>, + clean_string(<<240, 159, 152, 138>>, #config{uescape=true}) + )} + ]. + + +fix_key_test_() -> + [ + {"binary key", ?_assertEqual(fix_key(<<"foo">>), <<"foo">>)}, + {"atom key", ?_assertEqual(fix_key(foo), <<"foo">>)}, + {"integer key", ?_assertEqual(fix_key(123), <<"123">>)} + ]. + + +datetime_test_() -> + [ + {"datetime", ?_assertEqual( + [start_array, {string, <<"2014-08-13T23:12:34Z">>}, end_array, end_json], + parse([start_array, {{2014,08,13},{23,12,34}}, end_array, end_json], []) + )}, + {"datetime", ?_assertEqual( + [start_array, {string, <<"2014-08-13T23:12:34.363369Z">>}, end_array, end_json], + parse([start_array, {{2014,08,13},{23,12,34.363369}}, end_array, end_json], []) + )} + ]. + + +timestamp_test_() -> + [ + {"timestamp", ?_assertEqual( + [start_array, {string, <<"2016-01-15T18:19:28Z">>}, end_array, end_json], + parse([start_array, {1452,881968,111772}, end_array, end_json], []) + )} + ]. + + +rogue_tuple_test_() -> + [ + {"kv in value position of object", ?_assertError( + badarg, + parse([start_object, <<"key">>, {<<"key">>, <<"value">>}, end_object, end_json], []) + )}, + {"kv in value position of list", ?_assertError( + badarg, + parse([start_array, {<<"key">>, <<"value">>}, end_array, end_json], []) + )} + ]. + + +-endif. diff --git a/test/data/jsx/jsx_to_json.core b/test/data/jsx/jsx_to_json.core new file mode 100644 index 0000000..663cf7c --- /dev/null +++ b/test/data/jsx/jsx_to_json.core @@ -0,0 +1,875 @@ +module 'jsx_to_json' ['finish'/1, + 'format'/2, + 'get_key'/1, + 'get_value'/1, + 'handle_event'/2, + 'init'/1, + 'insert'/2, + 'module_info'/0, + 'module_info'/1, + 'start_array'/1, + 'start_json'/0, + 'start_json'/1, + 'start_object'/1, + 'to_json'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[116|[111|[95|[106|[115|[111|[110|[46|[101|[114|[108]]]]]]]]]]]]]]],1}], + %% Line 32 + 'record' = + %% Line 32 + [{'config',[{'record_field',33,{'atom',33,'space'},{'integer',33,0}}|[{'record_field',34,{'atom',34,'indent'},{'integer',34,0}}|[{'record_field',35,{'atom',35,'depth'},{'integer',35,0}}|[{'record_field',36,{'atom',36,'newline'},{'bin',36,[{'bin_element',36,{'char',36,10},'default','default'}]}}]]]]}], + %% Line 39 + 'type' = + %% Line 39 + [{'config',{'type',39,'list',[]},[]}], + %% Line 40 + 'export_type' = + %% Line 40 + [{'config',0}], + %% Line 43 + 'spec' = + %% Line 43 + [{{'to_json',2},[{'type',43,'fun',[{'type',43,'product',[{'ann_type',43,[{'var',43,'Source'}|[{'type',43,'any',[]}]]}|[{'ann_type',43,[{'var',43,'Config'}|[{'user_type',43,'config',[]}]]}]]}|[{'type',43,'binary',[]}]]}]}], + %% Line 49 + 'spec' = + %% Line 49 + [{{'format',2},[{'type',49,'fun',[{'type',49,'product',[{'ann_type',49,[{'var',49,'Source'}|[{'type',49,'binary',[]}]]}|[{'ann_type',49,[{'var',49,'Config'}|[{'user_type',49,'config',[]}]]}]]}|[{'type',49,'binary',[]}]]}]}], + %% Line 93 + 'type' = + %% Line 93 + [{'state',{'type',93,'tuple',[{'remote_type',93,[{'atom',93,'unicode'}|[{'atom',93,'charlist'}|[[]]]]}|[{'type',93,'record',[{'atom',93,'config'}]}]]},[]}], + %% Line 94 + 'spec' = + %% Line 94 + [{{'init',1},[{'type',94,'fun',[{'type',94,'product',[{'ann_type',94,[{'var',94,'Config'}|[{'remote_type',94,[{'atom',94,'proplists'}|[{'atom',94,'proplist'}|[[]]]]}]]}]}|[{'user_type',94,'state',[]}]]}]}], + %% Line 99 + 'spec' = + %% Line 99 + [{{'handle_event',2},[{'type',99,'fun',[{'type',99,'product',[{'ann_type',99,[{'var',99,'Event'}|[{'type',99,'any',[]}]]}|[{'ann_type',99,[{'var',99,'State'}|[{'user_type',99,'state',[]}]]}]]}|[{'user_type',99,'state',[]}]]}]}]] +'to_json'/2 = + %% Line 45 + fun (_0,_1) -> + case <_0,_1> of + + when call 'erlang':'is_list' + (Config) -> + let <_2> = + call %% Line 46 + 'erlang':%% Line 46 + '++' + (%% Line 46 + Config, %% Line 46 + ['escaped_strings']) + in let <_3> = + call %% Line 46 + 'jsx_config':%% Line 46 + 'extract_config' + (_2) + in let <_4> = + call %% Line 46 + 'jsx':%% Line 46 + 'encoder' + (%% Line 46 + 'jsx_to_json', %% Line 46 + Config, _3) + in %% Line 46 + apply _4 + (Source) + ( <_6,_5> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5}) + -| [{'function_name',{'to_json',2}}] ) + -| ['compiler_generated'] ) + end +'format'/2 = + %% Line 51 + fun (_0,_1) -> + case <_0,_1> of + + when try + ( let <_4> = + case call 'erlang':'is_binary' + (Source) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'is_list' + (Config) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_2> when 'true' -> + _2 + -| ['compiler_generated'] ) + end + in ( call 'erlang':'=:=' + (( _4 + -| ['compiler_generated'] ), 'true') + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' -> + let <_5> = + call %% Line 52 + 'erlang':%% Line 52 + '++' + (%% Line 52 + Config, %% Line 52 + ['escaped_strings']) + in let <_6> = + call %% Line 52 + 'jsx_config':%% Line 52 + 'extract_config' + (_5) + in let <_7> = + call %% Line 52 + 'jsx':%% Line 52 + 'decoder' + (%% Line 52 + 'jsx_to_json', %% Line 52 + Config, _6) + in %% Line 52 + apply _7 + (Source) + %% Line 53 + <_10,_11> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'parse_config'/1 = + %% Line 56 + fun (_0) -> + apply 'parse_config'/2 + (_0, {'config',0,0,0,#{#<10>(8,1,'integer',['unsigned'|['big']])}#}) +'parse_config'/2 = + %% Line 58 + fun (_0,_1) -> + case <_0,_1> of + <[{'space',Val}|Rest],Config> + when let <_2> = + call 'erlang':'is_integer' + (Val) + in let <_3> = + call 'erlang':'>' + (Val, 0) + in call 'erlang':'and' + (_2, _3) -> + %% Line 59 + case Config of + <{'config',_27,_28,_29,_30}> when 'true' -> + let <_6> = + call 'erlang':'setelement' + (2, Config, Val) + in apply 'parse_config'/2 + (Rest, _6) + ( <_31> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 60 + <['space'|Rest],Config> when 'true' -> + %% Line 61 + case Config of + <{'config',_32,_33,_34,_35}> when 'true' -> + let <_9> = + call 'erlang':'setelement' + (2, Config, 1) + in apply 'parse_config'/2 + (Rest, _9) + ( <_36> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 62 + <[{'indent',Val}|Rest],Config> + when let <_10> = + call 'erlang':'is_integer' + (Val) + in let <_11> = + call 'erlang':'>' + (Val, 0) + in call 'erlang':'and' + (_10, _11) -> + %% Line 63 + case Config of + <{'config',_37,_38,_39,_40}> when 'true' -> + let <_14> = + call 'erlang':'setelement' + (3, Config, Val) + in apply 'parse_config'/2 + (Rest, _14) + ( <_41> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 64 + <['indent'|Rest],Config> when 'true' -> + %% Line 65 + case Config of + <{'config',_42,_43,_44,_45}> when 'true' -> + let <_17> = + call 'erlang':'setelement' + (3, Config, 1) + in apply 'parse_config'/2 + (Rest, _17) + ( <_46> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 66 + <[{'newline',Val}|Rest],Config> + when call 'erlang':'is_binary' + (Val) -> + %% Line 67 + case Config of + <{'config',_47,_48,_49,_50}> when 'true' -> + let <_20> = + call 'erlang':'setelement' + (5, Config, Val) + in apply 'parse_config'/2 + (Rest, _20) + ( <_51> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 68 + when 'true' -> + let <_21> = + call %% Line 69 + 'jsx_config':%% Line 69 + 'valid_flags' + () + in %% Line 69 + case call 'lists':'member' + (K, _21) of + %% Line 70 + <'true'> when 'true' -> + apply 'parse_config'/2 + (Rest, Config) + %% Line 71 + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg', [Options|[Config|[]]]) + ( <_22> when 'true' -> + primop 'match_fail' + ({'case_clause',_22}) + -| ['compiler_generated'] ) + end + %% Line 73 + when 'true' -> + let <_23> = + call %% Line 74 + 'jsx_config':%% Line 74 + 'valid_flags' + () + in %% Line 74 + case call 'lists':'member' + (K, _23) of + %% Line 75 + <'true'> when 'true' -> + apply 'parse_config'/2 + (Rest, Config) + %% Line 76 + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg', [Options|[Config|[]]]) + ( <_24> when 'true' -> + primop 'match_fail' + ({'case_clause',_24}) + -| ['compiler_generated'] ) + end + %% Line 78 + <[],Config> when 'true' -> + %% Line 79 + Config + ( <_26,_25> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_26,_25}) + -| [{'function_name',{'parse_config',2}}] ) + -| ['compiler_generated'] ) + end +'init'/1 = + %% Line 96 + fun (_0) -> + let <_1> = + apply 'parse_config'/1 + (_0) + in {[],_1} +'handle_event'/2 = + %% Line 101 + fun (_0,_1) -> + case <_0,_1> of + <'end_json',State> when 'true' -> + apply 'get_value'/1 + (State) + %% Line 103 + <'start_object',State> when 'true' -> + apply 'start_object'/1 + (State) + %% Line 104 + <'end_object',State> when 'true' -> + apply 'finish'/1 + (State) + %% Line 106 + <'start_array',State> when 'true' -> + apply 'start_array'/1 + (State) + %% Line 107 + <'end_array',State> when 'true' -> + apply 'finish'/1 + (State) + %% Line 109 + <{Type,Event},State = {_5,Config}> when 'true' -> + let <_2> = + apply 'encode'/3 + (Type, Event, Config) + in apply 'insert'/2 + (_2, State) + ( <_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_4,_3}) + -| [{'function_name',{'handle_event',2}}] ) + -| ['compiler_generated'] ) + end +'encode'/3 = + %% Line 112 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <'string',String,_X_Config> when 'true' -> + %% Line 113 + [#{#<34>(8,1,'integer',['unsigned'|['big']])}#|[String|[#{#<34>(8,1,'integer',['unsigned'|['big']])}#]]] + %% Line 114 + <'key',Key,_X_Config> when 'true' -> + %% Line 115 + [#{#<34>(8,1,'integer',['unsigned'|['big']])}#|[Key|[#{#<34>(8,1,'integer',['unsigned'|['big']])}#]]] + %% Line 116 + <'literal',Literal,_X_Config> when 'true' -> + %% Line 117 + call 'erlang':'atom_to_list' + (Literal) + %% Line 118 + <'integer',Integer,_X_Config> when 'true' -> + %% Line 119 + call 'erlang':'integer_to_list' + (Integer) + %% Line 120 + <'float',Float,_X_Config> when 'true' -> + %% Line 121 + call 'io_lib':'format' + ([126|[112]], [Float|[]]) + ( <_5,_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4,_3}) + -| [{'function_name',{'encode',3}}] ) + -| ['compiler_generated'] ) + end +'space'/1 = + %% Line 124 + fun (_0) -> + %% Line 125 + ( case _0 of + ( <( {'config',_rec5,_5,_6,_7} + -| ['compiler_generated'] )> when 'true' -> + case _rec5 of + %% Line 126 + <0> when 'true' -> + #{}# + %% Line 127 + + when call 'erlang':'>' + (_rec5, + 0) -> + call 'binary':'copy' + (#{#<32>(8,1,'integer',['unsigned'|['big']])}#, X) + ( <_3> when 'true' -> + primop 'match_fail' + ({'case_clause',_3}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_8> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'indent'/1 = + %% Line 131 + fun (_0) -> + %% Line 132 + ( case _0 of + ( <( {'config',_11,_rec6,_12,_13} + -| ['compiler_generated'] )> when 'true' -> + case _rec6 of + %% Line 133 + <0> when 'true' -> + #{}# + %% Line 134 + + when call 'erlang':'>' + (_rec6, + 0) -> + ( case _0 of + ( <( {'config',_15,_16,_17,_rec8} + -| ['compiler_generated'] )> when 'true' -> + ( case _0 of + ( <( {'config',_19,_20,_rec7,_21} + -| ['compiler_generated'] )> when 'true' -> + let <_5> = + call 'erlang':'*' + (X, _rec7) + in let <_6> = + call 'binary':'copy' + (#{#<32>(8,1,'integer',['unsigned'|['big']])}#, _5) + in #{#<_rec8>('all',8,'binary',['unsigned'|['big']]), + #<_6>('all',8,'binary',['unsigned'|['big']])}# + -| ['compiler_generated'] ) + ( <_22> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_18> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_9> when 'true' -> + primop 'match_fail' + ({'case_clause',_9}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_14> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'indent_or_space'/1 = + %% Line 138 + fun (_0) -> + %% Line 139 + ( case _0 of + ( <( {'config',_5,_rec9,_6,_7} + -| ['compiler_generated'] )> when 'true' -> + case <> of + %% Line 140 + <> + when call 'erlang':'>' + (_rec9, + 0) -> + apply 'indent'/1 + (_0) + %% Line 141 + <> when 'true' -> + apply 'space'/1 + (_0) + end + -| ['compiler_generated'] ) + ( <_8> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'start_json'/0 = + %% Line 157 + fun () -> + {[],{'config',0,0,0,#{#<10>(8,1,'integer',['unsigned'|['big']])}#}} +'start_json'/1 = + %% Line 159 + fun (_0) -> + case _0 of + + when call 'erlang':'is_list' + (_0) -> + let <_1> = + apply 'parse_config'/1 + (Config) + in {[],_1} + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'start_json',1}}] ) + -| ['compiler_generated'] ) + end +'start_object'/1 = + %% Line 162 + fun (_0) -> + case _0 of + <{Stack,Config = {'config',_7,_8,Depth,_9}}> when 'true' -> + let <_5> = + [{'object',#{#<123>(8,1,'integer',['unsigned'|['big']])}#}|%% Line 163 + Stack] + in let <_rec10> = + call %% Line 163 + 'erlang':%% Line 163 + '+' + (%% Line 163 + Depth, %% Line 163 + 1) + in %% Line 163 + case Config of + <{'config',_10,_11,_12,_13}> when 'true' -> + let <_4> = + call 'erlang':'setelement' + (4, Config, _rec10) + in {_5,_4} + ( <_14> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + ( <_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6}) + -| [{'function_name',{'start_object',1}}] ) + -| ['compiler_generated'] ) + end +'start_array'/1 = + %% Line 166 + fun (_0) -> + case _0 of + <{Stack,Config = {'config',_7,_8,Depth,_9}}> when 'true' -> + let <_5> = + [{'array',#{#<91>(8,1,'integer',['unsigned'|['big']])}#}|%% Line 167 + Stack] + in let <_rec12> = + call %% Line 167 + 'erlang':%% Line 167 + '+' + (%% Line 167 + Depth, %% Line 167 + 1) + in %% Line 167 + case Config of + <{'config',_10,_11,_12,_13}> when 'true' -> + let <_4> = + call 'erlang':'setelement' + (4, Config, _rec12) + in {_5,_4} + ( <_14> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + ( <_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6}) + -| [{'function_name',{'start_array',1}}] ) + -| ['compiler_generated'] ) + end +'finish'/1 = + %% Line 170 + fun (_0) -> + case _0 of + <{Stack,Config = {'config',_7,_8,Depth,_9}}> when 'true' -> + let <_rec14> = + call %% Line 171 + 'erlang':%% Line 171 + '-' + (%% Line 171 + Depth, %% Line 171 + 1) + in %% Line 171 + case Config of + <{'config',_10,_11,_12,_13}> when 'true' -> + let <_4> = + call 'erlang':'setelement' + (4, Config, _rec14) + in %% Line 172 + apply 'finish_'/1 + ({Stack,_4}) + ( <_14> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + ( <_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6}) + -| [{'function_name',{'finish',1}}] ) + -| ['compiler_generated'] ) + end +'finish_'/1 = + %% Line 174 + fun (_0) -> + case _0 of + <{[{'object',#{#<123>(8,1,'integer',['unsigned'|['big']])}#}|[]],Config}> when 'true' -> + {#{#<123>(8,1,'integer',['unsigned'|['big']]), + #<125>(8,1,'integer',['unsigned'|['big']])}#,Config} + %% Line 175 + <{[{'array',#{#<91>(8,1,'integer',['unsigned'|['big']])}#}|[]],Config}> when 'true' -> + {#{#<91>(8,1,'integer',['unsigned'|['big']]), + #<93>(8,1,'integer',['unsigned'|['big']])}#,Config} + %% Line 176 + <{[{'object',#{#<123>(8,1,'integer',['unsigned'|['big']])}#}|Rest],Config}> when 'true' -> + apply 'insert'/2 + (#{#<123>(8,1,'integer',['unsigned'|['big']]), + #<125>(8,1,'integer',['unsigned'|['big']])}#, {Rest,Config}) + %% Line 177 + <{[{'array',#{#<91>(8,1,'integer',['unsigned'|['big']])}#}|Rest],Config}> when 'true' -> + apply 'insert'/2 + (#{#<91>(8,1,'integer',['unsigned'|['big']]), + #<93>(8,1,'integer',['unsigned'|['big']])}#, {Rest,Config}) + %% Line 178 + <{[{'object',Object}|[]],Config}> when 'true' -> + let <_1> = + apply %% Line 179 + 'indent'/1 + (%% Line 179 + Config) + in %% Line 179 + {[Object|[_1|[#{#<125>(8,1,'integer',['unsigned'|['big']])}#]]],Config} + %% Line 180 + <{[{'object',Object}|Rest],Config}> when 'true' -> + let <_2> = + apply %% Line 181 + 'indent'/1 + (%% Line 181 + Config) + in %% Line 181 + apply 'insert'/2 + ([Object|[_2|[#{#<125>(8,1,'integer',['unsigned'|['big']])}#]]], {Rest,Config}) + %% Line 182 + <{[{'array',Array}|[]],Config}> when 'true' -> + let <_3> = + apply %% Line 183 + 'indent'/1 + (%% Line 183 + Config) + in %% Line 183 + {[Array|[_3|[#{#<93>(8,1,'integer',['unsigned'|['big']])}#]]],Config} + %% Line 184 + <{[{'array',Array}|Rest],Config}> when 'true' -> + let <_4> = + apply %% Line 185 + 'indent'/1 + (%% Line 185 + Config) + in %% Line 185 + apply 'insert'/2 + ([Array|[_4|[#{#<93>(8,1,'integer',['unsigned'|['big']])}#]]], {Rest,Config}) + %% Line 186 + <_6> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'insert'/2 = + %% Line 189 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + %% Line 190 + {Value,Config} + %% Line 192 + when 'true' -> + let <_2> = + [%% Line 193 + {'object',Key,Object}|%% Line 193 + Rest] + in %% Line 193 + {_2,Config} + %% Line 194 + (8,1,'integer',['unsigned'|['big']])}#}|Rest],Config}> when 'true' -> + let <_3> = + apply %% Line 198 + 'indent'/1 + (%% Line 198 + Config) + in let <_4> = + apply %% Line 201 + 'space'/1 + (%% Line 201 + Config) + in let <_5> = + [%% Line 196 + {'object',[%% Line 197 + #{#<123>(8,1,'integer',['unsigned'|['big']])}#|%% Line 198 + [_3|%% Line 199 + [Key|%% Line 200 + [#{#<58>(8,1,'integer',['unsigned'|['big']])}#|%% Line 201 + [_4|%% Line 202 + [Value|%% Line 203 + []]]]]]]}|%% Line 203 + Rest] + in %% Line 195 + {_5,%% Line 204 + Config} + %% Line 206 + when 'true' -> + let <_6> = + apply %% Line 211 + 'indent_or_space'/1 + (%% Line 211 + Config) + in let <_7> = + apply %% Line 214 + 'space'/1 + (%% Line 214 + Config) + in let <_8> = + [%% Line 208 + {'object',[%% Line 209 + Object|%% Line 210 + [#{#<44>(8,1,'integer',['unsigned'|['big']])}#|%% Line 211 + [_6|%% Line 212 + [Key|%% Line 213 + [#{#<58>(8,1,'integer',['unsigned'|['big']])}#|%% Line 214 + [_7|%% Line 215 + [Value|%% Line 216 + []]]]]]]]}|%% Line 216 + Rest] + in %% Line 207 + {_8,%% Line 217 + Config} + %% Line 219 + (8,1,'integer',['unsigned'|['big']])}#}|Rest],Config}> when 'true' -> + let <_9> = + apply %% Line 220 + 'indent'/1 + (%% Line 220 + Config) + in let <_10> = + [%% Line 220 + {'array',[#{#<91>(8,1,'integer',['unsigned'|['big']])}#|[_9|[Value|[]]]]}|%% Line 220 + Rest] + in %% Line 220 + {_10,Config} + %% Line 221 + when 'true' -> + let <_11> = + apply %% Line 225 + 'indent_or_space'/1 + (%% Line 225 + Config) + in let <_12> = + [%% Line 223 + {'array',[Array|%% Line 224 + [#{#<44>(8,1,'integer',['unsigned'|['big']])}#|%% Line 225 + [_11|%% Line 226 + [Value|%% Line 227 + []]]]]}|%% Line 227 + Rest] + in %% Line 222 + {_12,%% Line 228 + Config} + %% Line 230 + <_15,_16> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'get_key'/1 = + %% Line 233 + fun (_0) -> + case _0 of + <{[{'object',Key,_2}|_3],_4}> when 'true' -> + Key + %% Line 234 + <_5> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'get_value'/1 = + %% Line 237 + fun (_0) -> + case _0 of + <{Value,_X_Config}> when 'true' -> + %% Line 238 + try + call 'unicode':'characters_to_binary' + (Value) + of <_1> -> + _1 + catch <_4,_3,_2> -> + %% Line 239 + case <_4,_3,_2> of + <( 'error' + -| ['compiler_generated'] ),_6,_7> when 'true' -> + call 'erlang':'error' + ('badarg') + ( <_9,_10,_11> when 'true' -> + primop 'raise' + (_11, _10) + -| ['compiler_generated'] ) + end + %% Line 241 + <_8> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('jsx_to_json') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('jsx_to_json', _0) +end \ No newline at end of file diff --git a/test/data/jsx/jsx_to_json.erl b/test/data/jsx/jsx_to_json.erl new file mode 100644 index 0000000..fb14df3 --- /dev/null +++ b/test/data/jsx/jsx_to_json.erl @@ -0,0 +1,409 @@ +%% The MIT License + +%% Copyright (c) 2010-2013 alisdair sullivan + +%% Permission is hereby granted, free of charge, to any person obtaining a copy +%% of this software and associated documentation files (the "Software"), to deal +%% in the Software without restriction, including without limitation the rights +%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%% copies of the Software, and to permit persons to whom the Software is +%% furnished to do so, subject to the following conditions: + +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. + +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +%% THE SOFTWARE. + + +-module(jsx_to_json). + +-export([to_json/2, format/2]). +-export([init/1, handle_event/2]). +-export([start_json/0, start_json/1]). +-export([start_object/1, start_array/1, finish/1, insert/2, get_key/1, get_value/1]). + + +-record(config, { + space = 0, + indent = 0, + depth = 0, + newline = <<$\n>> +}). + +-type config() :: list(). +-export_type([config/0]). + + +-spec to_json(Source::any(), Config::config()) -> binary(). + +to_json(Source, Config) when is_list(Config) -> + (jsx:encoder(?MODULE, Config, jsx_config:extract_config(Config ++ [escaped_strings])))(Source). + + +-spec format(Source::binary(), Config::config()) -> binary(). + +format(Source, Config) when is_binary(Source) andalso is_list(Config) -> + (jsx:decoder(?MODULE, Config, jsx_config:extract_config(Config ++ [escaped_strings])))(Source); +format(_, _) -> erlang:error(badarg). + + +parse_config(Config) -> parse_config(Config, #config{}). + +parse_config([{space, Val}|Rest], Config) when is_integer(Val), Val > 0 -> + parse_config(Rest, Config#config{space = Val}); +parse_config([space|Rest], Config) -> + parse_config(Rest, Config#config{space = 1}); +parse_config([{indent, Val}|Rest], Config) when is_integer(Val), Val > 0 -> + parse_config(Rest, Config#config{indent = Val}); +parse_config([indent|Rest], Config) -> + parse_config(Rest, Config#config{indent = 1}); +parse_config([{newline, Val}|Rest], Config) when is_binary(Val) -> + parse_config(Rest, Config#config{newline = Val}); +parse_config([{K, _}|Rest] = Options, Config) -> + case lists:member(K, jsx_config:valid_flags()) of + true -> parse_config(Rest, Config) + ; false -> erlang:error(badarg, [Options, Config]) + end; +parse_config([K|Rest] = Options, Config) -> + case lists:member(K, jsx_config:valid_flags()) of + true -> parse_config(Rest, Config) + ; false -> erlang:error(badarg, [Options, Config]) + end; +parse_config([], Config) -> + Config. + + +-define(start_object, <<"{">>). +-define(start_array, <<"[">>). +-define(end_object, <<"}">>). +-define(end_array, <<"]">>). +-define(colon, <<":">>). +-define(comma, <<",">>). +-define(quote, <<"\"">>). +-define(space, <<" ">>). +-define(newline, <<"\n">>). + + +-type state() :: {unicode:charlist(), #config{}}. +-spec init(Config::proplists:proplist()) -> state(). + +init(Config) -> {[], parse_config(Config)}. + + +-spec handle_event(Event::any(), State::state()) -> state(). + +handle_event(end_json, State) -> get_value(State); + +handle_event(start_object, State) -> start_object(State); +handle_event(end_object, State) -> finish(State); + +handle_event(start_array, State) -> start_array(State); +handle_event(end_array, State) -> finish(State); + +handle_event({Type, Event}, {_, Config} = State) -> insert(encode(Type, Event, Config), State). + + +encode(string, String, _Config) -> + [?quote, String, ?quote]; +encode(key, Key, _Config) -> + [?quote, Key, ?quote]; +encode(literal, Literal, _Config) -> + erlang:atom_to_list(Literal); +encode(integer, Integer, _Config) -> + erlang:integer_to_list(Integer); +encode(float, Float, _Config) -> + io_lib:format("~p", [Float]). + + +space(Config) -> + case Config#config.space of + 0 -> <<>> + ; X when X > 0 -> binary:copy(?space, X) + end. + + +indent(Config) -> + case Config#config.indent of + 0 -> <<>> + ; X when X > 0 -> <<(Config#config.newline)/binary, (binary:copy(?space, X * Config#config.depth))/binary>> + end. + + +indent_or_space(Config) -> + case Config#config.indent > 0 of + true -> indent(Config) + ; false -> space(Config) + end. + + +%% internal state is a stack and a config object +%% `{Stack, Config}` +%% the stack is a list of in progress objects/arrays +%% `[Current, Parent, Grandparent,...OriginalAncestor]` +%% an object has the representation on the stack of +%% `{object, Object}` +%% of if there's a key with a yet to be matched value +%% `{object, Key, Object}` +%% an array looks like +%% `{array, Array}` +%% `Object` and `Array` are utf8 encoded binaries + +start_json() -> {[], #config{}}. + +start_json(Config) when is_list(Config) -> {[], parse_config(Config)}. + +%% allocate a new object on top of the stack +start_object({Stack, Config = #config{depth = Depth}}) -> + {[{object, ?start_object}] ++ Stack, Config#config{depth = Depth + 1}}. + +%% allocate a new array on top of the stack +start_array({Stack, Config = #config{depth = Depth}}) -> + {[{array, ?start_array}] ++ Stack, Config#config{depth = Depth + 1}}. + +%% finish an object or array and insert it into the parent object if it exists +finish({Stack, Config = #config{depth = Depth}}) -> + NewConfig = Config#config{depth = Depth - 1}, + finish_({Stack, NewConfig}). + +finish_({[{object, <<"{">>}], Config}) -> {<<"{}">>, Config}; +finish_({[{array, <<"[">>}], Config}) -> {<<"[]">>, Config}; +finish_({[{object, <<"{">>}|Rest], Config}) -> insert(<<"{}">>, {Rest, Config}); +finish_({[{array, <<"[">>}|Rest], Config}) -> insert(<<"[]">>, {Rest, Config}); +finish_({[{object, Object}], Config}) -> + {[Object, indent(Config), ?end_object], Config}; +finish_({[{object, Object}|Rest], Config}) -> + insert([Object, indent(Config), ?end_object], {Rest, Config}); +finish_({[{array, Array}], Config}) -> + {[Array, indent(Config), ?end_array], Config}; +finish_({[{array, Array}|Rest], Config}) -> + insert([Array, indent(Config), ?end_array], {Rest, Config}); +finish_(_) -> erlang:error(badarg). + +%% insert a value when there's no parent object or array +insert(Value, {[], Config}) -> + {Value, Config}; +%% insert a key or value into an object or array, autodetects the 'right' thing +insert(Key, {[{object, Object}|Rest], Config}) -> + {[{object, Key, Object}] ++ Rest, Config}; +insert(Value, {[{object, Key, ?start_object}|Rest], Config}) -> + { + [{object, [ + ?start_object, + indent(Config), + Key, + ?colon, + space(Config), + Value + ]}] ++ Rest, + Config + }; +insert(Value, {[{object, Key, Object}|Rest], Config}) -> + { + [{object, [ + Object, + ?comma, + indent_or_space(Config), + Key, + ?colon, + space(Config), + Value + ]}] ++ Rest, + Config + }; +insert(Value, {[{array, ?start_array}|Rest], Config}) -> + {[{array, [?start_array, indent(Config), Value]}] ++ Rest, Config}; +insert(Value, {[{array, Array}|Rest], Config}) -> + { + [{array, [Array, + ?comma, + indent_or_space(Config), + Value + ]}] ++ Rest, + Config + }; +insert(_, _) -> erlang:error(badarg). + + +get_key({[{object, Key, _}|_], _}) -> Key; +get_key(_) -> erlang:error(badarg). + + +get_value({Value, _Config}) -> + try unicode:characters_to_binary(Value) + catch error:_ -> erlang:error(badarg) + end; +get_value(_) -> erlang:error(badarg). + + + +%% eunit tests + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + + +config_test_() -> + [ + {"empty config", ?_assertEqual(#config{}, parse_config([]))}, + {"unspecified indent/space", ?_assertEqual( + #config{space=1, indent=1}, + parse_config([space, indent]) + )}, + {"specific indent", ?_assertEqual( + #config{indent=4}, + parse_config([{indent, 4}]) + )}, + {"specific space", ?_assertEqual( + #config{space=2}, + parse_config([{space, 2}]) + )}, + {"specific space and indent", ?_assertEqual( + #config{space=2, indent=2}, + parse_config([{space, 2}, {indent, 2}]) + )}, + {"invalid opt flag", ?_assertError(badarg, parse_config([error]))}, + {"invalid opt tuple", ?_assertError(badarg, parse_config([{error, true}]))} + ]. + + +space_test_() -> + [ + {"no space", ?_assertEqual(<<>>, space(#config{space=0}))}, + {"one space", ?_assertEqual(<<" ">>, space(#config{space=1}))}, + {"four spaces", ?_assertEqual(<<" ">>, space(#config{space=4}))} + ]. + + +indent_test_() -> + [ + {"no indent", ?_assertEqual(<<>>, indent(#config{indent=0, depth=1}))}, + {"indent 1 depth 1", ?_assertEqual( + <>/binary>>, + indent(#config{indent=1, depth=1}) + )}, + {"indent 1 depth 2", ?_assertEqual( + <>/binary>>, + indent(#config{indent=1, depth=2}) + )}, + {"indent 4 depth 1", ?_assertEqual( + <>/binary>>, + indent(#config{indent=4, depth=1}) + )}, + {"indent 4 depth 2", ?_assertEqual( + <>/binary, <<" ">>/binary>>, + indent(#config{indent=4, depth=2}) + )} + ]. + + +indent_or_space_test_() -> + [ + {"no indent so space", ?_assertEqual( + <<" ">>, + indent_or_space(#config{space=1, indent=0, depth=1}) + )}, + {"indent so no space", ?_assertEqual( + <>/binary>>, + indent_or_space(#config{space=1, indent=1, depth=1}) + )} + ]. + + +encode_test_() -> + [ + {"0.0", ?_assert(encode(float, 0.0, #config{}) =:= ["0.0"])}, + {"1.0", ?_assert(encode(float, 1.0, #config{}) =:= ["1.0"])}, + {"-1.0", ?_assert(encode(float, -1.0, #config{}) =:= ["-1.0"])}, + {"3.1234567890987654321", + ?_assert( + encode(float, 3.1234567890987654321, #config{}) =:= ["3.1234567890987655"]) + }, + {"1.0e23", ?_assert(encode(float, 1.0e23, #config{}) =:= ["1.0e23"])}, + {"0.3", ?_assert(encode(float, 3.0/10.0, #config{}) =:= ["0.3"])}, + {"0.0001", ?_assert(encode(float, 0.0001, #config{}) =:= ["0.0001"])}, + {"0.00001", ?_assert(encode(float, 0.00001, #config{}) =:= ["1.0e-5"])}, + {"0.00000001", ?_assert(encode(float, 0.00000001, #config{}) =:= ["1.0e-8"])}, + {"1.0e-323", ?_assert(encode(float, 1.0e-323, #config{}) =:= ["1.0e-323"])}, + {"1.0e308", ?_assert(encode(float, 1.0e308, #config{}) =:= ["1.0e308"])}, + {"min normalized float", + ?_assert( + encode(float, math:pow(2, -1022), #config{}) =:= ["2.2250738585072014e-308"] + ) + }, + {"max normalized float", + ?_assert( + encode(float, (2 - math:pow(2, -52)) * math:pow(2, 1023), #config{}) + =:= ["1.7976931348623157e308"] + ) + }, + {"min denormalized float", + ?_assert(encode(float, math:pow(2, -1074), #config{}) =:= ["5.0e-324"]) + }, + {"max denormalized float", + ?_assert( + encode(float, (1 - math:pow(2, -52)) * math:pow(2, -1022), #config{}) + =:= ["2.225073858507201e-308"] + ) + }, + {"hello world", ?_assert(encode(string, <<"hello world">>, #config{}) + =:= [<<"\"">>, <<"hello world">>, <<"\"">>] + )}, + {"key", ?_assert(encode(key, <<"key">>, #config{}) =:= [<<"\"">>, <<"key">>, <<"\"">>])}, + {"1", ?_assert(encode(integer, 1, #config{}) =:= "1")}, + {"-1", ?_assert(encode(integer, -1, #config{}) =:= "-1")}, + {"true", ?_assert(encode(literal, true, #config{}) =:= "true")}, + {"false", ?_assert(encode(literal, false, #config{}) =:= "false")}, + {"null", ?_assert(encode(literal, null, #config{}) =:= "null")} + ]. + + +format_test_() -> + % {minified version, pretty version} + Cases = [ + {"empty object", <<"{}">>, <<"{}">>}, + {"empty array", <<"[]">>, <<"[]">>}, + {"single key object", <<"{\"k\":\"v\"}">>, <<"{\n \"k\": \"v\"\n}">>}, + {"single member array", <<"[true]">>, <<"[\n true\n]">>}, + {"multiple key object", + <<"{\"k\":\"v\",\"x\":\"y\"}">>, + <<"{\n \"k\": \"v\",\n \"x\": \"y\"\n}">> + }, + {"multiple member array", + <<"[1.0,2.0,3.0]">>, + <<"[\n 1.0,\n 2.0,\n 3.0\n]">> + }, + {"nested structure", + <<"[[{},[],true],{\"k\":\"v\",\"x\":\"y\"}]">>, + <<"[\n [\n {},\n [],\n true\n ],\n {\n \"k\": \"v\",\n \"x\": \"y\"\n }\n]">> + } + ], + [{Title, ?_assertEqual(Min, jsx:minify(Pretty))} || {Title, Min, Pretty} <- Cases] ++ + [{Title, ?_assertEqual(Pretty, jsx:prettify(Min))} || {Title, Min, Pretty} <- Cases]. + +custom_newline_test_() -> + [ + {"single key object", ?_assert( + jsx:format(<<"{\"k\":\"v\"}">>, [space, {indent, 2}, {newline, <<$\r>>}]) + =:= <<"{\r \"k\": \"v\"\r}">>) + } + ]. + +handle_event_test_() -> + Data = jsx:test_cases() ++ jsx:special_test_cases(), + [ + { + Title, ?_assertEqual( + JSON, + lists:foldl(fun handle_event/2, init([]), Events ++ [end_json]) + ) + } || {Title, JSON, _, Events} <- Data + ]. + + +-endif. diff --git a/test/data/jsx/jsx_to_term.core b/test/data/jsx/jsx_to_term.core new file mode 100644 index 0000000..b72d54b --- /dev/null +++ b/test/data/jsx/jsx_to_term.core @@ -0,0 +1,535 @@ +module 'jsx_to_term' ['finish'/1, + 'get_key'/1, + 'get_value'/1, + 'handle_event'/2, + 'init'/1, + 'insert'/2, + 'module_info'/0, + 'module_info'/1, + 'start_array'/1, + 'start_object'/1, + 'start_term'/1, + 'to_term'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[116|[111|[95|[116|[101|[114|[109|[46|[101|[114|[108]]]]]]]]]]]]]]],1}], + %% Line 39 + 'record' = + %% Line 39 + [{'config',[{'record_field',40,{'atom',40,'labels'},{'atom',40,'binary'}}|[{'record_field',41,{'atom',41,'return_maps'},{'atom',41,'false'}}]]}], + %% Line 44 + 'type' = + %% Line 44 + [{'config',{'type',44,'list',[]},[]}], + %% Line 45 + 'export_type' = + %% Line 45 + [{'config',0}], + %% Line 48 + 'type' = + %% Line 48 + [{'json_value',{'type',48,'union',[{'type',48,'list',[{'user_type',48,'json_value',[]}]}|[{'type',49,'list',[{'type',49,'tuple',[{'type',49,'union',[{'type',49,'binary',[]}|[{'type',49,'atom',[]}]]}|[{'user_type',49,'json_value',[]}]]}]}|[{'type',49,'nonempty_list',[{'type',49,'tuple',[]}]}|[{'atom',50,'true'}|[{'atom',51,'false'}|[{'atom',52,'null'}|[{'type',53,'integer',[]}|[{'type',54,'float',[]}|[{'type',55,'binary',[]}]]]]]]]]]},[]}], + %% Line 71 + 'spec' = + %% Line 71 + [{{'to_term',2},[{'type',71,'fun',[{'type',71,'product',[{'ann_type',71,[{'var',71,'Source'}|[{'type',71,'binary',[]}]]}|[{'ann_type',71,[{'var',71,'Config'}|[{'user_type',71,'config',[]}]]}]]}|[{'user_type',71,'json_value',[]}]]}]}], + %% Line 108 + 'type' = + %% Line 108 + [{'state',{'type',108,'tuple',[{'type',108,'list',[]}|[{'type',108,'record',[{'atom',108,'config'}]}]]},[]}], + %% Line 109 + 'spec' = + %% Line 109 + [{{'init',1},[{'type',109,'fun',[{'type',109,'product',[{'ann_type',109,[{'var',109,'Config'}|[{'remote_type',109,[{'atom',109,'proplists'}|[{'atom',109,'proplist'}|[[]]]]}]]}]}|[{'user_type',109,'state',[]}]]}]}], + %% Line 113 + 'spec' = + %% Line 113 + [{{'handle_event',2},[{'type',113,'fun',[{'type',113,'product',[{'ann_type',113,[{'var',113,'Event'}|[{'type',113,'any',[]}]]}|[{'ann_type',113,[{'var',113,'State'}|[{'user_type',113,'state',[]}]]}]]}|[{'user_type',113,'state',[]}]]}]}]] +'to_term'/2 = + %% Line 78 + fun (_0,_1) -> + case <_0,_1> of + + when call 'erlang':'is_list' + (Config) -> + let <_2> = + call %% Line 79 + 'jsx_config':%% Line 79 + 'extract_config' + (%% Line 79 + Config) + in let <_3> = + call %% Line 79 + 'jsx':%% Line 79 + 'decoder' + (%% Line 79 + 'jsx_to_term', %% Line 79 + Config, _2) + in %% Line 79 + apply _3 + (Source) + ( <_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4}) + -| [{'function_name',{'to_term',2}}] ) + -| ['compiler_generated'] ) + end +'parse_config'/1 = + %% Line 82 + fun (_0) -> + apply 'parse_config'/2 + (_0, {'config','binary','false'}) +'parse_config'/2 = + %% Line 84 + fun (_0,_1) -> + case <_0,_1> of + <[{'labels',Val}|Rest],Config> + when let <_2> = + call %% Line 85 + 'erlang':%% Line 85 + '=:=' + (%% Line 85 + Val, %% Line 85 + 'binary') + in let <_3> = + call %% Line 85 + 'erlang':%% Line 85 + '=:=' + (%% Line 85 + Val, %% Line 85 + 'atom') + in let <_4> = + call %% Line 85 + 'erlang':%% Line 85 + '=:=' + (%% Line 85 + Val, %% Line 85 + 'existing_atom') + in let <_5> = + call %% Line 85 + 'erlang':%% Line 85 + '=:=' + (%% Line 85 + Val, %% Line 85 + 'attempt_atom') + in let <_6> = + call %% Line 85 + 'erlang':%% Line 85 + 'or' + (_4, _5) + in let <_7> = + call %% Line 85 + 'erlang':%% Line 85 + 'or' + (_3, _6) + in %% Line 85 + call 'erlang':'or' + (_2, _7) -> + %% Line 86 + case Config of + <{'config',_28,_29}> when 'true' -> + let <_10> = + call 'erlang':'setelement' + (2, Config, Val) + in apply 'parse_config'/2 + (Rest, _10) + ( <_30> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 87 + <['labels'|Rest],Config> when 'true' -> + %% Line 88 + case Config of + <{'config',_31,_32}> when 'true' -> + let <_13> = + call 'erlang':'setelement' + (2, Config, 'binary') + in apply 'parse_config'/2 + (Rest, _13) + ( <_33> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 89 + <[{'return_maps',Val}|Rest],Config> + when let <_14> = + call %% Line 90 + 'erlang':%% Line 90 + '=:=' + (%% Line 90 + Val, %% Line 90 + 'true') + in let <_15> = + call %% Line 90 + 'erlang':%% Line 90 + '=:=' + (%% Line 90 + Val, %% Line 90 + 'false') + in %% Line 90 + call 'erlang':'or' + (_14, _15) -> + %% Line 91 + case Config of + <{'config',_34,_35}> when 'true' -> + let <_18> = + call 'erlang':'setelement' + (3, Config, Val) + in apply 'parse_config'/2 + (Rest, _18) + ( <_36> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 92 + <['return_maps'|Rest],Config> when 'true' -> + %% Line 93 + case Config of + <{'config',_37,_38}> when 'true' -> + let <_21> = + call 'erlang':'setelement' + (3, Config, 'true') + in apply 'parse_config'/2 + (Rest, _21) + ( <_39> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 94 + when 'true' -> + let <_22> = + call %% Line 95 + 'jsx_config':%% Line 95 + 'valid_flags' + () + in %% Line 95 + case call 'lists':'member' + (K, _22) of + %% Line 96 + <'true'> when 'true' -> + apply 'parse_config'/2 + (Rest, Config) + %% Line 97 + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg', [Options|[Config|[]]]) + ( <_23> when 'true' -> + primop 'match_fail' + ({'case_clause',_23}) + -| ['compiler_generated'] ) + end + %% Line 99 + when 'true' -> + let <_24> = + call %% Line 100 + 'jsx_config':%% Line 100 + 'valid_flags' + () + in %% Line 100 + case call 'lists':'member' + (K, _24) of + %% Line 101 + <'true'> when 'true' -> + apply 'parse_config'/2 + (Rest, Config) + %% Line 102 + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg', [Options|[Config|[]]]) + ( <_25> when 'true' -> + primop 'match_fail' + ({'case_clause',_25}) + -| ['compiler_generated'] ) + end + %% Line 104 + <[],Config> when 'true' -> + %% Line 105 + Config + ( <_27,_26> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_27,_26}) + -| [{'function_name',{'parse_config',2}}] ) + -| ['compiler_generated'] ) + end +'init'/1 = + %% Line 111 + fun (_0) -> + apply 'start_term'/1 + (_0) +'handle_event'/2 = + %% Line 115 + fun (_0,_1) -> + case <_0,_1> of + <'end_json',State> when 'true' -> + apply 'get_value'/1 + (State) + %% Line 117 + <'start_object',State> when 'true' -> + apply 'start_object'/1 + (State) + %% Line 118 + <'end_object',State> when 'true' -> + apply 'finish'/1 + (State) + %% Line 120 + <'start_array',State> when 'true' -> + apply 'start_array'/1 + (State) + %% Line 121 + <'end_array',State> when 'true' -> + apply 'finish'/1 + (State) + %% Line 123 + <{'key',Key},State = {_5,Config}> when 'true' -> + let <_2> = + apply 'format_key'/2 + (Key, Config) + in apply 'insert'/2 + (_2, State) + %% Line 125 + <{_6,Event},State> when 'true' -> + apply 'insert'/2 + (Event, State) + ( <_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_4,_3}) + -| [{'function_name',{'handle_event',2}}] ) + -| ['compiler_generated'] ) + end +'format_key'/2 = + %% Line 128 + fun (_0,_1) -> + %% Line 129 + ( case _1 of + ( <( {'config',_rec4,_12} + -| ['compiler_generated'] )> when 'true' -> + case _rec4 of + %% Line 130 + <'binary'> when 'true' -> + _0 + %% Line 131 + <'atom'> when 'true' -> + call 'erlang':'binary_to_atom' + (_0, 'utf8') + %% Line 132 + <'existing_atom'> when 'true' -> + call 'erlang':'binary_to_existing_atom' + (_0, 'utf8') + %% Line 133 + <'attempt_atom'> when 'true' -> + %% Line 134 + try + call 'erlang':'binary_to_existing_atom' + (_0, 'utf8') + of <_4> -> + _4 + catch <_8,_7,_6> -> + %% Line 137 + case <_8,_7,_6> of + <( 'error' + -| ['compiler_generated'] ),( 'badarg' + -| ['compiler_generated'] ),_14> when 'true' -> + _0 + ( <_16,_17,_18> when 'true' -> + primop 'raise' + (_18, _17) + -| ['compiler_generated'] ) + end + ( <_9> when 'true' -> + primop 'match_fail' + ({'case_clause',_9}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_13> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','config'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'start_term'/1 = + %% Line 165 + fun (_0) -> + case _0 of + + when call 'erlang':'is_list' + (_0) -> + let <_1> = + apply 'parse_config'/1 + (Config) + in {[],_1} + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'start_term',1}}] ) + -| ['compiler_generated'] ) + end +'start_object'/1 = + %% Line 170 + fun (_0) -> + case _0 of + <{Stack,Config}> when 'true' -> + let <_1> = + [{'object',[]}|Stack] + in {_1,Config} + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'start_object',1}}] ) + -| ['compiler_generated'] ) + end +'start_array'/1 = + %% Line 174 + fun (_0) -> + case _0 of + <{Stack,Config}> when 'true' -> + let <_1> = + [{'array',[]}|Stack] + in {_1,Config} + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'start_array',1}}] ) + -| ['compiler_generated'] ) + end +'finish'/1 = + %% Line 179 + fun (_0) -> + case _0 of + <{[{'object',[]}],Config}> when 'true' -> + {[{}],Config} + %% Line 180 + <{[{'object',[]}|Rest],Config}> when 'true' -> + apply 'insert'/2 + ([{}], {Rest,Config}) + %% Line 181 + <{[{'object',Pairs}|[]],Config}> when 'true' -> + let <_1> = + call 'lists':'reverse' + (Pairs) + in {_1,Config} + %% Line 182 + <{[{'object',Pairs}|Rest],Config}> when 'true' -> + let <_2> = + call 'lists':'reverse' + (Pairs) + in apply 'insert'/2 + (_2, {Rest,Config}) + %% Line 183 + <{[{'array',Values}|[]],Config}> when 'true' -> + let <_3> = + call 'lists':'reverse' + (Values) + in {_3,Config} + %% Line 184 + <{[{'array',Values}|Rest],Config}> when 'true' -> + let <_4> = + call 'lists':'reverse' + (Values) + in apply 'insert'/2 + (_4, {Rest,Config}) + %% Line 185 + <_6> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'insert'/2 = + %% Line 189 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + {Value,Config} + %% Line 191 + when 'true' -> + let <_2> = + [%% Line 192 + {'object',Key,Pairs}|%% Line 192 + Rest] + in %% Line 192 + {_2,Config} + %% Line 193 + when 'true' -> + let <_3> = + [%% Line 194 + {Key,Value}|%% Line 194 + Pairs] + in let <_4> = + [%% Line 194 + {'object',_3}|%% Line 194 + Rest] + in %% Line 194 + {_4,Config} + %% Line 195 + when 'true' -> + let <_5> = + [%% Line 196 + Value|%% Line 196 + Values] + in let <_6> = + [%% Line 196 + {'array',_5}|%% Line 196 + Rest] + in %% Line 196 + {_6,Config} + %% Line 197 + <_9,_10> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'get_key'/1 = + %% Line 243 + fun (_0) -> + case _0 of + <{[{'object',Key,_2}|_3],_4}> when 'true' -> + Key + %% Line 244 + <_5> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'get_value'/1 = + %% Line 247 + fun (_0) -> + case _0 of + <{Value,_X_Config}> when 'true' -> + Value + %% Line 248 + <_2> when 'true' -> + call 'erlang':'error' + ('badarg') + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('jsx_to_term') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('jsx_to_term', _0) +end \ No newline at end of file diff --git a/test/data/jsx/jsx_to_term.erl b/test/data/jsx/jsx_to_term.erl new file mode 100644 index 0000000..e4e5f5e --- /dev/null +++ b/test/data/jsx/jsx_to_term.erl @@ -0,0 +1,459 @@ +%% The MIT License + +%% Copyright (c) 2010-2013 Alisdair Sullivan + +%% Permission is hereby granted, free of charge, to any person obtaining a copy +%% of this software and associated documentation files (the "Software"), to deal +%% in the Software without restriction, including without limitation the rights +%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%% copies of the Software, and to permit persons to whom the Software is +%% furnished to do so, subject to the following conditions: + +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. + +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +%% THE SOFTWARE. + + +-module(jsx_to_term). + +-export([to_term/2]). +-export([init/1, handle_event/2]). +-export([ + start_term/1, + start_object/1, + start_array/1, + finish/1, + insert/2, + get_key/1, + get_value/1 +]). + + +-record(config, { + labels = binary, + return_maps = false +}). + +-type config() :: list(). +-export_type([config/0]). + +-ifndef(maps_support). +-type json_value() :: list(json_value()) + | list({binary() | atom(), json_value()}) | [{},...] + | true + | false + | null + | integer() + | float() + | binary(). +-endif. + +-ifdef(maps_support). +-type json_value() :: list(json_value()) + | list({binary() | atom(), json_value()}) | [{},...] + | map() + | true + | false + | null + | integer() + | float() + | binary(). +-endif. + + +-spec to_term(Source::binary(), Config::config()) -> json_value(). + +-ifdef(maps_always). +to_term(Source, Config) when is_list(Config) -> + (jsx:decoder(?MODULE, [return_maps] ++ Config, jsx_config:extract_config(Config)))(Source). +-endif. +-ifndef(maps_always). +to_term(Source, Config) when is_list(Config) -> + (jsx:decoder(?MODULE, Config, jsx_config:extract_config(Config)))(Source). +-endif. + +parse_config(Config) -> parse_config(Config, #config{}). + +parse_config([{labels, Val}|Rest], Config) + when Val == binary; Val == atom; Val == existing_atom; Val == attempt_atom -> + parse_config(Rest, Config#config{labels = Val}); +parse_config([labels|Rest], Config) -> + parse_config(Rest, Config#config{labels = binary}); +parse_config([{return_maps, Val}|Rest], Config) + when Val == true; Val == false -> + parse_config(Rest, Config#config{return_maps = Val}); +parse_config([return_maps|Rest], Config) -> + parse_config(Rest, Config#config{return_maps = true}); +parse_config([{K, _}|Rest] = Options, Config) -> + case lists:member(K, jsx_config:valid_flags()) of + true -> parse_config(Rest, Config) + ; false -> erlang:error(badarg, [Options, Config]) + end; +parse_config([K|Rest] = Options, Config) -> + case lists:member(K, jsx_config:valid_flags()) of + true -> parse_config(Rest, Config) + ; false -> erlang:error(badarg, [Options, Config]) + end; +parse_config([], Config) -> + Config. + + +-type state() :: {list(), #config{}}. +-spec init(Config::proplists:proplist()) -> state(). + +init(Config) -> start_term(Config). + +-spec handle_event(Event::any(), State::state()) -> state(). + +handle_event(end_json, State) -> get_value(State); + +handle_event(start_object, State) -> start_object(State); +handle_event(end_object, State) -> finish(State); + +handle_event(start_array, State) -> start_array(State); +handle_event(end_array, State) -> finish(State); + +handle_event({key, Key}, {_, Config} = State) -> insert(format_key(Key, Config), State); + +handle_event({_, Event}, State) -> insert(Event, State). + + +format_key(Key, Config) -> + case Config#config.labels of + binary -> Key + ; atom -> binary_to_atom(Key, utf8) + ; existing_atom -> binary_to_existing_atom(Key, utf8) + ; attempt_atom -> + try binary_to_existing_atom(Key, utf8) of + Result -> Result + catch + error:badarg -> Key + end + end. + + +%% internal state is a stack and a config object +%% `{Stack, Config}` +%% the stack is a list of in progress objects/arrays +%% `[Current, Parent, Grandparent,...OriginalAncestor]` +%% an object has the representation on the stack of +%% `{object, [ +%% {NthKey, NthValue}, +%% {NMinus1Key, NthMinus1Value}, +%% ..., +%% {FirstKey, FirstValue} +%% ]}` +%% or if returning maps +%% `{object, #{ +%% FirstKey => FirstValue, +%% SecondKey => SecondValue, +%% ..., +%% NthKey => NthValue +%% }}` +%% or if there's a key with a yet to be matched value +%% `{object, Key, ...}` +%% an array looks like +%% `{array, [NthValue, NthMinus1Value,...FirstValue]}` + +start_term(Config) when is_list(Config) -> {[], parse_config(Config)}. + + +-ifndef(maps_support). +%% allocate a new object on top of the stack +start_object({Stack, Config}) -> {[{object, []}] ++ Stack, Config}. + + +%% allocate a new array on top of the stack +start_array({Stack, Config}) -> {[{array, []}] ++ Stack, Config}. + + +%% finish an object or array and insert it into the parent object if it exists or +%% return it if it is the root object +finish({[{object, []}], Config}) -> {[{}], Config}; +finish({[{object, []}|Rest], Config}) -> insert([{}], {Rest, Config}); +finish({[{object, Pairs}], Config}) -> {lists:reverse(Pairs), Config}; +finish({[{object, Pairs}|Rest], Config}) -> insert(lists:reverse(Pairs), {Rest, Config}); +finish({[{array, Values}], Config}) -> {lists:reverse(Values), Config}; +finish({[{array, Values}|Rest], Config}) -> insert(lists:reverse(Values), {Rest, Config}); +finish(_) -> erlang:error(badarg). + + +%% insert a value when there's no parent object or array +insert(Value, {[], Config}) -> {Value, Config}; +%% insert a key or value into an object or array, autodetects the 'right' thing +insert(Key, {[{object, Pairs}|Rest], Config}) -> + {[{object, Key, Pairs}] ++ Rest, Config}; +insert(Value, {[{object, Key, Pairs}|Rest], Config}) -> + {[{object, [{Key, Value}] ++ Pairs}] ++ Rest, Config}; +insert(Value, {[{array, Values}|Rest], Config}) -> + {[{array, [Value] ++ Values}] ++ Rest, Config}; +insert(_, _) -> erlang:error(badarg). +-endif. + + +-ifdef(maps_support). +%% allocate a new object on top of the stack +start_object({Stack, Config=#config{return_maps=true}}) -> + {[{object, #{}}] ++ Stack, Config}; +start_object({Stack, Config}) -> + {[{object, []}] ++ Stack, Config}. + + +%% allocate a new array on top of the stack +start_array({Stack, Config}) -> {[{array, []}] ++ Stack, Config}. + + +%% finish an object or array and insert it into the parent object if it exists or +%% return it if it is the root object +finish({[{object, Map}], Config=#config{return_maps=true}}) -> {Map, Config}; +finish({[{object, Map}|Rest], Config=#config{return_maps=true}}) -> insert(Map, {Rest, Config}); +finish({[{object, []}], Config}) -> {[{}], Config}; +finish({[{object, []}|Rest], Config}) -> insert([{}], {Rest, Config}); +finish({[{object, Pairs}], Config}) -> {lists:reverse(Pairs), Config}; +finish({[{object, Pairs}|Rest], Config}) -> insert(lists:reverse(Pairs), {Rest, Config}); +finish({[{array, Values}], Config}) -> {lists:reverse(Values), Config}; +finish({[{array, Values}|Rest], Config}) -> insert(lists:reverse(Values), {Rest, Config}); +finish(_) -> erlang:error(badarg). + + +%% insert a value when there's no parent object or array +insert(Value, {[], Config}) -> {Value, Config}; +%% insert a key or value into an object or array, autodetects the 'right' thing +insert(Key, {[{object, Map}|Rest], Config=#config{return_maps=true}}) -> + {[{object, Key, Map}] ++ Rest, Config}; +insert(Key, {[{object, Pairs}|Rest], Config}) -> + {[{object, Key, Pairs}] ++ Rest, Config}; +insert(Value, {[{object, Key, Map}|Rest], Config=#config{return_maps=true}}) -> + {[{object, maps:put(Key, Value, Map)}] ++ Rest, Config}; +insert(Value, {[{object, Key, Pairs}|Rest], Config}) -> + {[{object, [{Key, Value}] ++ Pairs}] ++ Rest, Config}; +insert(Value, {[{array, Values}|Rest], Config}) -> + {[{array, [Value] ++ Values}] ++ Rest, Config}; +insert(_, _) -> erlang:error(badarg). +-endif. + + +get_key({[{object, Key, _}|_], _}) -> Key; +get_key(_) -> erlang:error(badarg). + + +get_value({Value, _Config}) -> Value; +get_value(_) -> erlang:error(badarg). + + + +%% eunit tests + +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + + +config_test_() -> + [ + {"empty config", ?_assertEqual(#config{}, parse_config([]))}, + {"implicit binary labels", ?_assertEqual(#config{}, parse_config([labels]))}, + {"binary labels", ?_assertEqual(#config{}, parse_config([{labels, binary}]))}, + {"atom labels", ?_assertEqual(#config{labels=atom}, parse_config([{labels, atom}]))}, + {"existing atom labels", ?_assertEqual( + #config{labels=existing_atom}, + parse_config([{labels, existing_atom}]) + )}, + {"return_maps true", ?_assertEqual( + #config{return_maps=true}, + parse_config([return_maps]) + )}, + {"invalid opt flag", ?_assertError(badarg, parse_config([error]))}, + {"invalid opt tuple", ?_assertError(badarg, parse_config([{error, true}]))} + ]. + + +format_key_test_() -> + [ + {"binary key", ?_assertEqual(<<"key">>, format_key(<<"key">>, #config{labels=binary}))}, + {"atom key", ?_assertEqual(key, format_key(<<"key">>, #config{labels=atom}))}, + {"existing atom key", ?_assertEqual( + key, + format_key(<<"key">>, #config{labels=existing_atom}) + )}, + {"nonexisting atom key", ?_assertError( + badarg, + format_key(<<"nonexistentatom">>, #config{labels=existing_atom}) + )}, + {"sloppy existing atom key", ?_assertEqual( + key, + format_key(<<"key">>, #config{labels=attempt_atom}) + )}, + {"nonexisting atom key", ?_assertEqual( + <<"nonexistentatom">>, + format_key(<<"nonexistentatom">>, #config{labels=attempt_atom}) + )} + ]. + + +rep_manipulation_test_() -> + [ + {"allocate a new context with option", ?_assertEqual( + {[], #config{labels=atom}}, + start_term([{labels, atom}]) + )}, + {"allocate a new object on an empty stack", ?_assertEqual( + {[{object, []}], #config{}}, + start_object({[], #config{}}) + )}, + {"allocate a new object on a stack", ?_assertEqual( + {[{object, []}, {object, []}], #config{}}, + start_object({[{object, []}], #config{}}) + )}, + {"allocate a new array on an empty stack", ?_assertEqual( + {[{array, []}], #config{}}, + start_array({[], #config{}}) + )}, + {"allocate a new array on a stack", ?_assertEqual( + {[{array, []}, {object, []}], #config{}}, + start_array({[{object, []}], #config{}}) + )}, + {"insert a key into an object", ?_assertEqual( + {[{object, key, []}, junk], #config{}}, + insert(key, {[{object, []}, junk], #config{}}) + )}, + {"get current key", ?_assertEqual( + key, + get_key({[{object, key, []}], #config{}}) + )}, + {"try to get non-key from object", ?_assertError( + badarg, + get_key({[{object, []}], #config{}}) + )}, + {"try to get key from array", ?_assertError( + badarg, + get_key({[{array, []}], #config{}}) + )}, + {"insert a value into an object", ?_assertEqual( + {[{object, [{key, value}]}, junk], #config{}}, + insert(value, {[{object, key, []}, junk], #config{}}) + )}, + {"insert a value into an array", ?_assertEqual( + {[{array, [value]}, junk], #config{}}, + insert(value, {[{array, []}, junk], #config{}}) + )}, + {"finish an object with no ancestor", ?_assertEqual( + {[{a, b}, {x, y}], #config{}}, + finish({[{object, [{x, y}, {a, b}]}], #config{}}) + )}, + {"finish an empty object", ?_assertEqual( + {[{}], #config{}}, + finish({[{object, []}], #config{}}) + )}, + {"finish an object with an ancestor", ?_assertEqual( + {[{object, [{key, [{a, b}, {x, y}]}, {foo, bar}]}], #config{}}, + finish({[{object, [{x, y}, {a, b}]}, {object, key, [{foo, bar}]}], #config{}}) + )}, + {"finish an array with no ancestor", ?_assertEqual( + {[a, b, c], #config{}}, + finish({[{array, [c, b, a]}], #config{}}) + )}, + {"finish an array with an ancestor", ?_assertEqual( + {[{array, [[a, b, c], d, e, f]}], #config{}}, + finish({[{array, [c, b, a]}, {array, [d, e, f]}], #config{}}) + )} + ]. + + +-ifdef(maps_support). +rep_manipulation_with_maps_test_() -> + [ + {"allocate a new object on an empty stack", ?_assertEqual( + {[{object, #{}}], #config{return_maps=true}}, + start_object({[], #config{return_maps=true}}) + )}, + {"allocate a new object on a stack", ?_assertEqual( + {[{object, #{}}, {object, #{}}], #config{return_maps=true}}, + start_object({[{object, #{}}], #config{return_maps=true}}) + )}, + {"insert a key into an object", ?_assertEqual( + {[{object, key, #{}}, junk], #config{return_maps=true}}, + insert(key, {[{object, #{}}, junk], #config{return_maps=true}}) + )}, + {"get current key", ?_assertEqual( + key, + get_key({[{object, key, #{}}], #config{return_maps=true}}) + )}, + {"try to get non-key from object", ?_assertError( + badarg, + get_key({[{object, #{}}], #config{return_maps=true}}) + )}, + {"insert a value into an object", ?_assertEqual( + {[{object, #{key => value}}, junk], #config{return_maps=true}}, + insert(value, {[{object, key, #{}}, junk], #config{return_maps=true}}) + )}, + {"finish an object with no ancestor", ?_assertEqual( + {#{a => b, x => y}, #config{return_maps=true}}, + finish({[{object, #{x => y, a => b}}], #config{return_maps=true}}) + )}, + {"finish an empty object", ?_assertEqual( + {#{}, #config{return_maps=true}}, + finish({[{object, #{}}], #config{return_maps=true}}) + )}, + {"finish an object with an ancestor", ?_assertEqual( + { + [{object, #{key => #{a => b, x => y}, foo => bar}}], + #config{return_maps=true} + }, + finish({ + [{object, #{x => y, a => b}}, {object, key, #{foo => bar}}], + #config{return_maps=true} + }) + )} + ]. + + +return_maps_test_() -> + [ + {"an empty map", ?_assertEqual( + #{}, + jsx:decode(<<"{}">>, [return_maps]) + )}, + {"an empty map", ?_assertEqual( + [{}], + jsx:decode(<<"{}">>, []) + )}, + {"an empty map", ?_assertEqual( + [{}], + jsx:decode(<<"{}">>, [{return_maps, false}]) + )}, + {"a small map", ?_assertEqual( + #{<<"awesome">> => true, <<"library">> => <<"jsx">>}, + jsx:decode(<<"{\"library\": \"jsx\", \"awesome\": true}">>, [return_maps]) + )}, + {"a recursive map", ?_assertEqual( + #{<<"key">> => #{<<"key">> => true}}, + jsx:decode(<<"{\"key\": {\"key\": true}}">>, [return_maps]) + )}, + {"a map inside a list", ?_assertEqual( + [#{}], + jsx:decode(<<"[{}]">>, [return_maps]) + )} + ]. +-endif. + + +handle_event_test_() -> + Data = jsx:test_cases(), + [ + { + Title, ?_assertEqual( + Term, + lists:foldl(fun handle_event/2, init([]), Events ++ [end_json]) + ) + } || {Title, _, Term, Events} <- Data + ]. + + +-endif. diff --git a/test/data/jsx/jsx_verify.core b/test/data/jsx/jsx_verify.core new file mode 100644 index 0000000..892da29 --- /dev/null +++ b/test/data/jsx/jsx_verify.core @@ -0,0 +1,215 @@ +module 'jsx_verify' ['handle_event'/2, + 'init'/1, + 'is_json'/2, + 'is_term'/2, + 'module_info'/0, + 'module_info'/1] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[106|[115|[120|[95|[118|[101|[114|[105|[102|[121|[46|[101|[114|[108]]]]]]]]]]]]]],1}], + %% Line 30 + 'spec' = + %% Line 30 + [{{'is_json',2},[{'type',30,'fun',[{'type',30,'product',[{'ann_type',30,[{'var',30,'Source'}|[{'type',30,'binary',[]}]]}|[{'ann_type',30,[{'var',30,'Config'}|[{'remote_type',30,[{'atom',30,'proplists'}|[{'atom',30,'proplist'}|[[]]]]}]]}]]}|[{'type',30,'union',[{'atom',30,'true'}|[{'atom',30,'false'}|[{'type',30,'tuple',[{'atom',30,'incomplete'}|[{'remote_type',30,[{'atom',30,'jsx'}|[{'atom',30,'decoder'}|[[]]]]}]]}]]]}]]}]}], + %% Line 38 + 'spec' = + %% Line 38 + [{{'is_term',2},[{'type',38,'fun',[{'type',38,'product',[{'ann_type',38,[{'var',38,'Source'}|[{'type',38,'any',[]}]]}|[{'ann_type',38,[{'var',38,'Config'}|[{'remote_type',38,[{'atom',38,'proplists'}|[{'atom',38,'proplist'}|[[]]]]}]]}]]}|[{'type',38,'union',[{'atom',38,'true'}|[{'atom',38,'false'}|[{'type',38,'tuple',[{'atom',38,'incomplete'}|[{'remote_type',38,[{'atom',38,'jsx'}|[{'atom',38,'encoder'}|[[]]]]}]]}]]]}]]}]}], + %% Line 70 + 'type' = + %% Line 70 + [{'state',{'type',70,'nil',[]},[]}], + %% Line 71 + 'spec' = + %% Line 71 + [{{'init',1},[{'type',71,'fun',[{'type',71,'product',[{'ann_type',71,[{'var',71,'Config'}|[{'remote_type',71,[{'atom',71,'proplists'}|[{'atom',71,'proplist'}|[[]]]]}]]}]}|[{'user_type',71,'state',[]}]]}]}], + %% Line 76 + 'spec' = + %% Line 76 + [{{'handle_event',2},[{'type',76,'fun',[{'type',76,'product',[{'ann_type',76,[{'var',76,'Event'}|[{'type',76,'any',[]}]]}|[{'ann_type',76,[{'var',76,'State'}|[{'user_type',76,'state',[]}]]}]]}|[{'user_type',76,'state',[]}]]}]}]] +'is_json'/2 = + %% Line 32 + fun (_0,_1) -> + case <_0,_1> of + + when call 'erlang':'is_list' + (Config) -> + %% Line 33 + try + let <_2> = + call 'jsx_config':'extract_config' + (Config) + in let <_3> = + call 'jsx':'decoder' + ('jsx_verify', Config, _2) + in apply _3 + (Source) + of <_4> -> + _4 + catch <_7,_6,_5> -> + %% Line 34 + case <_7,_6,_5> of + <( 'error' + -| ['compiler_generated'] ),( 'badarg' + -| ['compiler_generated'] ),_10> when 'true' -> + 'false' + ( <_11,_12,_13> when 'true' -> + primop 'raise' + (_13, _12) + -| ['compiler_generated'] ) + end + ( <_9,_8> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_9,_8}) + -| [{'function_name',{'is_json',2}}] ) + -| ['compiler_generated'] ) + end +'is_term'/2 = + %% Line 40 + fun (_0,_1) -> + case <_0,_1> of + + when call 'erlang':'is_list' + (Config) -> + %% Line 41 + try + let <_2> = + call 'jsx_config':'extract_config' + (Config) + in let <_3> = + call 'jsx':'encoder' + ('jsx_verify', Config, _2) + in apply _3 + (Source) + of <_4> -> + _4 + catch <_7,_6,_5> -> + %% Line 42 + case <_7,_6,_5> of + <( 'error' + -| ['compiler_generated'] ),( 'badarg' + -| ['compiler_generated'] ),_10> when 'true' -> + 'false' + ( <_11,_12,_13> when 'true' -> + primop 'raise' + (_13, _12) + -| ['compiler_generated'] ) + end + ( <_9,_8> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_9,_8}) + -| [{'function_name',{'is_term',2}}] ) + -| ['compiler_generated'] ) + end +'parse_config'/1 = + %% Line 46 + fun (_0) -> + apply 'parse_config'/2 + (_0, []) +'parse_config'/2 = + %% Line 49 + fun (_0,_1) -> + case <_0,_1> of + <['no_repeated_keys'|Rest],Config> when 'true' -> + %% Line 50 + apply 'parse_config'/2 + (Rest, Config) + %% Line 51 + <[{'repeated_keys',Val}|Rest],Config> + when let <_2> = + call 'erlang':'=:=' + (Val, 'true') + in let <_3> = + call 'erlang':'=:=' + (Val, 'false') + in call 'erlang':'or' + (_2, _3) -> + %% Line 52 + apply 'parse_config'/2 + (Rest, Config) + %% Line 53 + <['repeated_keys'|Rest],Config> when 'true' -> + %% Line 54 + apply 'parse_config'/2 + (Rest, Config) + %% Line 55 + when 'true' -> + let <_4> = + call %% Line 56 + 'jsx_config':%% Line 56 + 'valid_flags' + () + in %% Line 56 + case call 'lists':'member' + (K, _4) of + %% Line 57 + <'true'> when 'true' -> + apply 'parse_config'/2 + (Rest, Config) + %% Line 58 + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg', [Options|[Config|[]]]) + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end + %% Line 60 + when 'true' -> + let <_6> = + call %% Line 61 + 'jsx_config':%% Line 61 + 'valid_flags' + () + in %% Line 61 + case call 'lists':'member' + (K, _6) of + %% Line 62 + <'true'> when 'true' -> + apply 'parse_config'/2 + (Rest, Config) + %% Line 63 + <'false'> when 'true' -> + call 'erlang':'error' + ('badarg', [Options|[Config|[]]]) + ( <_7> when 'true' -> + primop 'match_fail' + ({'case_clause',_7}) + -| ['compiler_generated'] ) + end + %% Line 65 + <[],Config> when 'true' -> + %% Line 66 + Config + ( <_9,_8> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_9,_8}) + -| [{'function_name',{'parse_config',2}}] ) + -| ['compiler_generated'] ) + end +'init'/1 = + %% Line 73 + fun (_0) -> + apply 'parse_config'/1 + (_0) +'handle_event'/2 = + %% Line 78 + fun (_0,_1) -> + case <_0,_1> of + <'end_json',_4> when 'true' -> + 'true' + %% Line 80 + <_5,State> when 'true' -> + State + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('jsx_verify') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('jsx_verify', _0) +end \ No newline at end of file diff --git a/test/data/jsx/jsx_verify.erl b/test/data/jsx/jsx_verify.erl new file mode 100644 index 0000000..5f4a3d8 --- /dev/null +++ b/test/data/jsx/jsx_verify.erl @@ -0,0 +1,119 @@ +%% The MIT License + +%% Copyright (c) 2010-2013 alisdair sullivan + +%% Permission is hereby granted, free of charge, to any person obtaining a copy +%% of this software and associated documentation files (the "Software"), to deal +%% in the Software without restriction, including without limitation the rights +%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%% copies of the Software, and to permit persons to whom the Software is +%% furnished to do so, subject to the following conditions: + +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. + +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +%% THE SOFTWARE. + + +-module(jsx_verify). + +-export([is_json/2, is_term/2]). +-export([init/1, handle_event/2]). + + +-spec is_json(Source::binary(), Config::proplists:proplist()) -> true | false | {incomplete, jsx:decoder()}. + +is_json(Source, Config) when is_list(Config) -> + try (jsx:decoder(?MODULE, Config, jsx_config:extract_config(Config)))(Source) + catch error:badarg -> false + end. + + +-spec is_term(Source::any(), Config::proplists:proplist()) -> true | false | {incomplete, jsx:encoder()}. + +is_term(Source, Config) when is_list(Config) -> + try (jsx:encoder(?MODULE, Config, jsx_config:extract_config(Config)))(Source) + catch error:badarg -> false + end. + + +parse_config(Config) -> parse_config(Config, []). + +%% ignore deprecated flags +parse_config([no_repeated_keys|Rest], Config) -> + parse_config(Rest, Config); +parse_config([{repeated_keys, Val}|Rest], Config) when Val == true; Val == false -> + parse_config(Rest, Config); +parse_config([repeated_keys|Rest], Config) -> + parse_config(Rest, Config); +parse_config([{K, _}|Rest] = Options, Config) -> + case lists:member(K, jsx_config:valid_flags()) of + true -> parse_config(Rest, Config); + false -> erlang:error(badarg, [Options, Config]) + end; +parse_config([K|Rest] = Options, Config) -> + case lists:member(K, jsx_config:valid_flags()) of + true -> parse_config(Rest, Config); + false -> erlang:error(badarg, [Options, Config]) + end; +parse_config([], Config) -> + Config. + + +%% we don't actually need any state for this +-type state() :: []. +-spec init(Config::proplists:proplist()) -> state(). + +init(Config) -> parse_config(Config). + + +-spec handle_event(Event::any(), State::state()) -> state(). + +handle_event(end_json, _) -> true; + +handle_event(_, State) -> State. + + + +%% eunit tests +-ifdef(TEST). +-include_lib("eunit/include/eunit.hrl"). + + +config_test_() -> + [ + {"empty config", ?_assertEqual([], parse_config([]))}, + {"no repeat keys", ?_assertEqual([], parse_config([no_repeated_keys]))}, + {"bare repeated keys", ?_assertEqual([], parse_config([repeated_keys]))}, + {"repeated keys true", ?_assertEqual( + [], + parse_config([{repeated_keys, true}]) + )}, + {"repeated keys false", ?_assertEqual( + [], + parse_config([{repeated_keys, false}]) + )}, + {"invalid opt flag", ?_assertError(badarg, parse_config([error]))}, + {"invalid opt tuple", ?_assertError(badarg, parse_config([{error, true}]))} + ]. + + +handle_event_test_() -> + Data = jsx:test_cases() ++ jsx:special_test_cases(), + [ + { + Title, ?_assertEqual( + true, + lists:foldl(fun handle_event/2, [], Events ++ [end_json]) + ) + } || {Title, _, _, Events} <- Data + ]. + + +-endif. diff --git a/test/data/sasl/alarm_handler.core b/test/data/sasl/alarm_handler.core new file mode 100644 index 0000000..608f013 --- /dev/null +++ b/test/data/sasl/alarm_handler.core @@ -0,0 +1,170 @@ +module 'alarm_handler' ['add_alarm_handler'/1, + 'add_alarm_handler'/2, + 'clear_alarm'/1, + 'delete_alarm_handler'/1, + 'get_alarms'/0, + 'handle_call'/2, + 'handle_event'/2, + 'handle_info'/2, + 'init'/1, + 'module_info'/0, + 'module_info'/1, + 'set_alarm'/1, + 'start_link'/0, + 'terminate'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[97|[108|[97|[114|[109|[95|[104|[97|[110|[100|[108|[101|[114|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]],1}]] +'start_link'/0 = + %% Line 35 + fun () -> + %% Line 36 + case call 'gen_event':'start_link' + ({'local','alarm_handler'}) of + %% Line 37 + <_@r0 = {'ok',Pid}> when 'true' -> + do %% Line 38 + call 'gen_event':'add_handler' + ('alarm_handler', 'alarm_handler', []) + %% Line 39 + _@r0 + %% Line 40 + when 'true' -> + Error + end +'set_alarm'/1 = + %% Line 48 + fun (_0) -> + %% Line 49 + call 'gen_event':'notify' + ('alarm_handler', {'set_alarm',_0}) +'clear_alarm'/1 = + %% Line 55 + fun (_0) -> + %% Line 56 + call 'gen_event':'notify' + ('alarm_handler', {'clear_alarm',_0}) +'get_alarms'/0 = + %% Line 62 + fun () -> + %% Line 63 + call 'gen_event':'call' + ('alarm_handler', 'alarm_handler', 'get_alarms') +'add_alarm_handler'/1 = + %% Line 65 + fun (_0) -> + case _0 of + + when call 'erlang':'is_atom' + (_0) -> + %% Line 66 + call 'gen_event':'add_handler' + ('alarm_handler', Module, []) + ( <_1> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_1}) + -| [{'function_name',{'add_alarm_handler',1}}] ) + -| ['compiler_generated'] ) + end +'add_alarm_handler'/2 = + %% Line 68 + fun (_0,_1) -> + case <_0,_1> of + + when call 'erlang':'is_atom' + (Module) -> + %% Line 69 + call 'gen_event':'add_handler' + ('alarm_handler', Module, Args) + ( <_3,_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3,_2}) + -| [{'function_name',{'add_alarm_handler',2}}] ) + -| ['compiler_generated'] ) + end +'delete_alarm_handler'/1 = + %% Line 71 + fun (_0) -> + case _0 of + + when call 'erlang':'is_atom' + (_0) -> + %% Line 72 + call 'gen_event':'delete_handler' + ('alarm_handler', Module, []) + ( <_1> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_1}) + -| [{'function_name',{'delete_alarm_handler',1}}] ) + -| ['compiler_generated'] ) + end +'init'/1 = + %% Line 77 + fun (_0) -> + {'ok',[]} +'handle_event'/2 = + %% Line 79 + fun (_0,_1) -> + case <_0,_1> of + <{'set_alarm',Alarm},Alarms> when 'true' -> + do %% Line 80 + call 'error_logger':'info_report' + ([{'alarm_handler',{'set',Alarm}}|[]]) + %% Line 81 + {'ok',[Alarm|Alarms]} + %% Line 82 + <{'clear_alarm',AlarmId},Alarms> when 'true' -> + do %% Line 83 + call 'error_logger':'info_report' + ([{'alarm_handler',{'clear',AlarmId}}|[]]) + let <_2> = + call %% Line 84 + 'lists':%% Line 84 + 'keydelete' + (%% Line 84 + AlarmId, %% Line 84 + 1, %% Line 84 + Alarms) + in %% Line 84 + {'ok',_2} + %% Line 85 + <_5,Alarms> when 'true' -> + %% Line 86 + {'ok',Alarms} + end +'handle_info'/2 = + %% Line 88 + fun (_0,_1) -> + {'ok',_1} +'handle_call'/2 = + %% Line 90 + fun (_0,_1) -> + case <_0,_1> of + <'get_alarms',Alarms> when 'true' -> + {'ok',Alarms,Alarms} + %% Line 91 + <_X_Query,Alarms> when 'true' -> + {'ok',{'error','bad_query'},Alarms} + end +'terminate'/2 = + %% Line 93 + fun (_0,_1) -> + case <_0,_1> of + <'swap',Alarms> when 'true' -> + %% Line 94 + {'alarm_handler',Alarms} + %% Line 95 + <_4,_5> when 'true' -> + %% Line 96 + 'ok' + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('alarm_handler') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('alarm_handler', _0) +end \ No newline at end of file diff --git a/test/data/sasl/erlsrv.core b/test/data/sasl/erlsrv.core new file mode 100644 index 0000000..27a5123 --- /dev/null +++ b/test/data/sasl/erlsrv.core @@ -0,0 +1,1387 @@ +module 'erlsrv' ['disable_service'/1, + 'disable_service'/2, + 'enable_service'/1, + 'enable_service'/2, + 'erlsrv'/1, + 'get_all_services'/0, + 'get_service'/1, + 'get_service'/2, + 'module_info'/0, + 'module_info'/1, + 'new_service'/3, + 'new_service'/4, + 'remove_service'/1, + 'rename_service'/2, + 'rename_service'/3, + 'store_service'/1, + 'store_service'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[101|[114|[108|[115|[114|[118|[46|[101|[114|[108]]]]]]]]]]]]]],1}]] +'erlsrv'/1 = + %% Line 32 + fun (_0) -> + let = + call %% Line 33 + 'code':%% Line 33 + 'root_dir' + () + in let <_2> = + call %% Line 34 + 'erlang':%% Line 34 + '++' + (%% Line 34 + [101|[114|[116|[115|[45]]]]], _0) + in %% Line 34 + call 'filename':'join' + ([Root|[_2|[[98|[105|[110]]]|[[101|[114|[108|[115|[114|[118|[46|[101|[120|[101]]]]]]]]]]]]]]) +'current_version'/0 = + %% Line 36 + fun () -> + let <_0> = + call %% Line 37 + 'erlang':%% Line 37 + 'system_info' + (%% Line 37 + 'version') + in let <_1> = + call %% Line 37 + 'string':%% Line 37 + 'lexemes' + (_0, %% Line 37 + [95|[32]]) + in %% Line 37 + call 'erlang':'hd' + (_1) +'run_erlsrv'/1 = + %% Line 40 + fun (_0) -> + let <_1> = + apply %% Line 41 + 'current_version'/0 + () + in %% Line 41 + apply 'run_erlsrv'/2 + (_1, _0) +'run_erlsrv'/2 = + %% Line 42 + fun (_0,_1) -> + let <_6> = + catch + let <_3> = + apply %% Line 43 + 'erlsrv'/1 + (_0) + in let <_2> = + [34|%% Line 43 + [32|_1]] + in let <_4> = + call %% Line 43 + 'erlang':%% Line 43 + '++' + (_3, _2) + in let <_5> = + [34|_4] + in %% Line 43 + call 'erlang':'open_port' + ({'spawn',_5}, %% Line 44 + [{'line',1000}|['in'|['eof']]]) + in %% Line 43 + case _6 of + %% Line 45 + <{'EXIT',{Reason,_11}}> when 'true' -> + %% Line 46 + {'port_error',Reason} + %% Line 47 + when 'true' -> + %% Line 48 + case apply 'read_all_data'/1 + (Port) of + %% Line 49 + <[]> when 'true' -> + %% Line 50 + 'failed' + %% Line 51 + when 'true' -> + %% Line 52 + {'ok',X} + end + end +'run_erlsrv_interactive'/2 = + %% Line 56 + fun (_0,_1) -> + let <_5> = + catch + let <_2> = + apply %% Line 57 + 'erlsrv'/1 + (_0) + in let <_3> = + call %% Line 57 + 'erlang':%% Line 57 + '++' + (_2, %% Line 57 + [34|[32|[114|[101|[97|[100|[97|[114|[103|[115]]]]]]]]]]) + in let <_4> = + [34|_3] + in %% Line 57 + call 'erlang':'open_port' + ({'spawn',_4}, %% Line 58 + [{'line',1000}|['eof']]) + in %% Line 57 + case _5 of + %% Line 59 + <{'EXIT',{Reason,_10}}> when 'true' -> + %% Line 60 + {'port_error',Reason} + %% Line 61 + when 'true' -> + do %% Line 62 + apply 'write_all_data'/2 + (Port, _1) + %% Line 63 + case apply 'read_all_data'/1 + (Port) of + %% Line 64 + <[]> when 'true' -> + %% Line 65 + 'failed' + %% Line 66 + when 'true' -> + %% Line 67 + {'ok',X} + end + end +'write_all_data'/2 = + %% Line 71 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + let <_3> = + call %% Line 72 + 'erlang':%% Line 72 + 'self' + () + in let <_2> = + call %% Line 72 + 'io_lib':%% Line 72 + 'nl' + () + in do %% Line 72 + call 'erlang':'!' + (Port, {_3,{'command',_2}}) + %% Line 73 + 'ok' + %% Line 74 + when 'true' -> + let <_6> = + call %% Line 75 + 'erlang':%% Line 75 + 'self' + () + in let <_4> = + call %% Line 75 + 'io_lib':%% Line 75 + 'nl' + () + in let <_5> = + call %% Line 75 + 'unicode':%% Line 75 + 'characters_to_binary' + (%% Line 75 + [H|[_4|[]]]) + in do %% Line 75 + call 'erlang':'!' + (Port, {_6,{'command',_5}}) + %% Line 76 + apply 'write_all_data'/2 + (Port, T) + ( <_8,_7> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_8,_7}) + -| [{'function_name',{'write_all_data',2}}] ) + -| ['compiler_generated'] ) + end +'read_all_data'/1 = + %% Line 78 + fun (_0) -> + let <_1> = + apply %% Line 79 + 'read_all_data'/3 + (_0, %% Line 79 + [], %% Line 79 + []) + in let = + call %% Line 79 + 'lists':%% Line 79 + 'reverse' + (_1) + in %% Line 81 + ( letrec + 'lc$^0'/1 = + fun (_5) -> + case _5 of + <[Data|_4]> when 'true' -> + let <_6> = + call 'erlang':'list_to_binary' + (Data) + in let <_7> = + call 'unicode':'characters_to_list' + (_6) + in let <_8> = + apply 'lc$^0'/1 + (_4) + in ( [_7|_8] + -| ['compiler_generated'] ) + <[]> when 'true' -> + [] + ( <_10> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_10}) + -| [{'function_name',{'lc$^0',1}}] ) + -| ['compiler_generated'] ) + end + in apply 'lc$^0'/1 + (Data0) + -| ['list_comprehension'] ) +'read_all_data'/3 = + %% Line 83 + fun (_0,_1,_2) -> + %% Line 84 + receive + %% Line 85 + <{_10,{'data',{'noeol',Data}}}> + when call 'erlang':'=:=' + (_10, + _0) -> + let <_3> = + call %% Line 86 + 'erlang':%% Line 86 + '++' + (_1, %% Line 86 + Data) + in %% Line 86 + apply 'read_all_data'/3 + (_0, _3, _2) + %% Line 87 + <{_11,{'data',{'eol',Data}}}> + when call 'erlang':'=:=' + (_11, + _0) -> + let <_4> = + call %% Line 88 + 'erlang':%% Line 88 + '++' + (_1, %% Line 88 + Data) + in %% Line 88 + apply 'read_all_data'/3 + (_0, [], [_4|_2]) + %% Line 89 + <{_12,_X_Other}> + when call 'erlang':'=:=' + (_12, + _0) -> + let <_5> = + call %% Line 90 + 'erlang':%% Line 90 + 'self' + () + in do %% Line 90 + call 'erlang':'!' + (_0, {_5,'close'}) + %% Line 91 + receive + %% Line 92 + <{_13,'closed'}> + when call 'erlang':'=:=' + (_13, + _0) -> + %% Line 93 + case _1 of + %% Line 94 + <[]> when 'true' -> + _2 + %% Line 95 + <_14> when 'true' -> + [_1|_2] + end + after 'infinity' -> + 'true' + after 'infinity' -> + 'true' +'get_all_services'/0 = + %% Line 102 + fun () -> + %% Line 103 + case apply 'run_erlsrv'/1 + ([108|[105|[115|[116]]]]) of + %% Line 104 + <'failed'> when 'true' -> + %% Line 105 + [] + %% Line 106 + <{'ok',[_5|[]]}> when 'true' -> + %% Line 107 + [] + %% Line 108 + <{'ok',[_X_H|T]}> when 'true' -> + let = + fun (_1) -> + let <_0> = + call %% Line 110 + 'string':%% Line 110 + 'lexemes' + (%% Line 109 + _1, %% Line 110 + [9|[32]]) + in %% Line 110 + call 'erlang':'hd' + (_0) + in %% Line 112 + call 'lists':'map' + (F, T) + %% Line 113 + <_6> when 'true' -> + %% Line 114 + {'error','external_program_failed'} + end +'disable_service'/1 = + %% Line 117 + fun (_0) -> + let <_1> = + apply %% Line 118 + 'current_version'/0 + () + in %% Line 118 + apply 'disable_service'/2 + (_1, _0) +'disable_service'/2 = + %% Line 119 + fun (_0,_1) -> + let <_2> = + call %% Line 120 + 'erlang':%% Line 120 + '++' + (%% Line 120 + [100|[105|[115|[97|[98|[108|[101|[32]]]]]]]], _1) + in %% Line 120 + apply 'run_erlsrv'/2 + (_0, _2) +'enable_service'/1 = + %% Line 121 + fun (_0) -> + let <_1> = + apply %% Line 122 + 'current_version'/0 + () + in %% Line 122 + apply 'enable_service'/2 + (_1, _0) +'enable_service'/2 = + %% Line 123 + fun (_0,_1) -> + let <_2> = + call %% Line 124 + 'erlang':%% Line 124 + '++' + (%% Line 124 + [101|[110|[97|[98|[108|[101|[32]]]]]]], _1) + in %% Line 124 + apply 'run_erlsrv'/2 + (_0, _2) +'remove_service'/1 = + %% Line 125 + fun (_0) -> + let <_1> = + call %% Line 126 + 'erlang':%% Line 126 + '++' + (%% Line 126 + [114|[101|[109|[111|[118|[101|[32]]]]]]], _0) + in %% Line 126 + apply 'run_erlsrv'/1 + (_1) +'rename_service'/2 = + %% Line 127 + fun (_0,_1) -> + let <_2> = + apply %% Line 128 + 'current_version'/0 + () + in %% Line 128 + apply 'rename_service'/3 + (_2, _0, _1) +'rename_service'/3 = + %% Line 129 + fun (_0,_1,_2) -> + let <_3> = + [32|_2] + in let <_4> = + call %% Line 130 + 'erlang':%% Line 130 + '++' + (_1, _3) + in let <_5> = + call %% Line 130 + 'erlang':%% Line 130 + '++' + (%% Line 130 + [114|[101|[110|[97|[109|[101|[32]]]]]]], _4) + in %% Line 130 + apply 'run_erlsrv'/2 + (_0, _5) +'get_service'/1 = + %% Line 152 + fun (_0) -> + let <_1> = + apply %% Line 153 + 'current_version'/0 + () + in %% Line 153 + apply 'get_service'/2 + (_1, _0) +'get_service'/2 = + %% Line 154 + fun (_0,_1) -> + let <_2> = + call %% Line 155 + 'erlang':%% Line 155 + '++' + (%% Line 155 + [108|[105|[115|[116|[32]]]]], _1) + in %% Line 155 + case apply 'run_erlsrv'/2 + (_0, _2) of + %% Line 156 + <'failed'> when 'true' -> + %% Line 157 + {'error','no_such_service'} + %% Line 158 + <_@r0 = {'port_error',Reason}> when 'true' -> + %% Line 159 + {'error',_@r0} + %% Line 160 + <{'ok',Data}> when 'true' -> + let = + fun (_6) -> + %% Line 175 + case apply 'splitline'/1 + (_6) of + <{Name,Value}> when 'true' -> + %% Line 176 + case call 'lists':'keysearch' + (Name, 1, [{[83|[101|[114|[118|[105|[99|[101|[32|[110|[97|[109|[101]]]]]]]]]]]],'servicename',[]}|[{[83|[116|[111|[112|[65|[99|[116|[105|[111|[110]]]]]]]]]],'stopaction',[]}|[{[79|[110|[70|[97|[105|[108]]]]]],'onfail',[105|[103|[110|[111|[114|[101]]]]]]}|[{[77|[97|[99|[104|[105|[110|[101]]]]]]],'machine',[]}|[{[87|[111|[114|[107|[68|[105|[114]]]]]]],'workdir',[]}|[{[83|[78|[97|[109|[101]]]]],'sname',[]}|[{[78|[97|[109|[101]]]],'name',[]}|[{[80|[114|[105|[111|[114|[105|[116|[121]]]]]]]],'priority',[100|[101|[102|[97|[117|[108|[116]]]]]]]}|[{[68|[101|[98|[117|[103|[84|[121|[112|[101]]]]]]]]],'debugtype',[110|[111|[110|[101]]]]}|[{[65|[114|[103|[115]]]],'args',[]}|[{[73|[110|[116|[101|[114|[110|[97|[108|[83|[101|[114|[118|[105|[99|[101|[78|[97|[109|[101]]]]]]]]]]]]]]]]]]],'internalservicename',[]}|[{[67|[111|[109|[109|[101|[110|[116]]]]]]],'comment',[]}]]]]]]]]]]]]) of + %% Line 177 + <{'value',{_28,_X_Atom,_29}}> + when let <_30> = + call 'erlang':'=:=' + (_28, Name) + in let <_31> = + call 'erlang':'=:=' + (_29, Value) + in call 'erlang':'and' + (_30, _31) -> + %% Line 178 + [] + %% Line 179 + <{'value',{_32,Atom,_33}}> + when call 'erlang':'=:=' + (_32, + Name) -> + %% Line 180 + {Atom,Value} + %% Line 181 + <_34> when 'true' -> + %% Line 182 + [] + end + ( <_4> when 'true' -> + primop 'match_fail' + ({'badmatch',_4}) + -| ['compiler_generated'] ) + end + in %% Line 186 + case apply 'split_by_env'/1 + (Data) of + <{Before,After}> when 'true' -> + let <_10> = + call %% Line 187 + 'lists':%% Line 187 + 'map' + (%% Line 187 + F, %% Line 187 + Before) + in let = + call %% Line 187 + 'lists':%% Line 187 + 'flatten' + (_10) + in let = + apply %% Line 189 + 'split_arglist'/1 + (%% Line 189 + FirstPass) + in let <_22> = + fun (_20) -> + let = + call %% Line 194 + 'string':%% Line 194 + 'trim' + (%% Line 193 + _20, %% Line 194 + 'leading', %% Line 194 + [36|[9]]) + in let <_14> = + call %% Line 195 + 'string':%% Line 195 + 'lexemes' + (%% Line 195 + X, %% Line 195 + [61]) + in %% Line 195 + case call 'erlang':'hd' + (_14) of + %% Line 196 + <_35> + when call 'erlang':'=:=' + (_35, + X) -> + %% Line 198 + {X,[]} + %% Line 199 + when 'true' -> + let <_16> = + call %% Line 201 + 'erlang':%% Line 201 + 'length' + (%% Line 201 + Y) + in let <_17> = + call %% Line 201 + 'erlang':%% Line 201 + '+' + (_16, %% Line 201 + 2) + in let <_15> = + call %% Line 202 + 'erlang':%% Line 202 + 'length' + (%% Line 202 + X) + in let <_18> = + call %% Line 201 + 'lists':%% Line 201 + 'sublist' + (%% Line 201 + X, _17, _15) + in %% Line 200 + {Y,_18} + end + in let = + call %% Line 192 + 'lists':%% Line 192 + 'map' + (_22, %% Line 205 + After) + in %% Line 206 + case EnvParts of + %% Line 207 + <[]> when 'true' -> + %% Line 208 + SecondPass + %% Line 209 + <_36> when 'true' -> + %% Line 210 + call 'lists':'append' + (SecondPass, [{'env',EnvParts}|[]]) + end + ( <_9> when 'true' -> + primop 'match_fail' + ({'badmatch',_9}) + -| ['compiler_generated'] ) + end + ( <_25> when 'true' -> + primop 'match_fail' + ({'case_clause',_25}) + -| ['compiler_generated'] ) + end +'store_service'/1 = + %% Line 215 + fun (_0) -> + let <_1> = + apply %% Line 216 + 'current_version'/0 + () + in %% Line 216 + apply 'store_service'/2 + (_1, _0) +'store_service'/2 = + %% Line 217 + fun (_0,_1) -> + %% Line 218 + case call 'lists':'keysearch' + ('servicename', 1, _1) of + %% Line 219 + <'false'> when 'true' -> + %% Line 220 + {'error','no_servicename'} + %% Line 221 + <{'value',{_12,Name}}> when 'true' -> + let <_16,_17> = + case %% Line 222 + apply 'get_service'/2 + (_0, Name) of + %% Line 223 + <{'error','no_such_service'}> when 'true' -> + %% Line 224 + <[97|[100|[100]]],_1> + %% Line 225 + <_13> when 'true' -> + let <_2> = + call %% Line 227 + 'lists':%% Line 227 + 'keydelete' + (%% Line 227 + 'internalservicename', %% Line 227 + 1, _1) + in %% Line 226 + <[115|[101|[116]]],_2> + end + in let <_6> = + apply %% Line 229 + 'build_commands'/2 + (%% Line 229 + Name, ( _17 + -| ['compiler_generated'] )) + in let = + [( _16 + -| ['compiler_generated'] )|_6] + in %% Line 230 + case apply 'run_erlsrv_interactive'/2 + (_0, Commands) of + %% Line 231 + <{'ok',_14}> when 'true' -> + %% Line 232 + 'ok' + %% Line 233 + when 'true' -> + %% Line 234 + {'error',X} + end + %% Line 236 + <_15> when 'true' -> + %% Line 237 + {'error','malformed_description'} + end +'build_commands'/2 = + %% Line 240 + fun (_0,_1) -> + let <_2> = + apply %% Line 241 + 'build_commands2'/2 + (_1, %% Line 241 + []) + in let <_3> = + call %% Line 241 + 'lists':%% Line 241 + 'reverse' + (_2) + in %% Line 241 + [_0|_3] +'build_commands2'/2 = + %% Line 243 + fun (_0,_1) -> + case <_0,_1> of + <[],A> when 'true' -> + %% Line 244 + A + %% Line 245 + <[{'env',[]}|T],A> when 'true' -> + %% Line 246 + apply 'build_commands2'/2 + (T, A) + %% Line 247 + <[{'env',[{Var,Val}|Et]}|T],A> when 'true' -> + let <_2> = + [61|%% Line 248 + Val] + in let <_3> = + call %% Line 248 + 'erlang':%% Line 248 + '++' + (%% Line 248 + Var, _2) + in %% Line 248 + apply 'build_commands2'/2 + ([{'env',Et}|T], [_3|[[45|[101|[110|[118]]]]|A]]) + %% Line 249 + <[{'servicename',_11}|T],A> when 'true' -> + %% Line 250 + apply 'build_commands2'/2 + (T, A) + %% Line 251 + <[{Atom,[]}|T],A> when 'true' -> + let <_4> = + call %% Line 252 + 'erlang':%% Line 252 + 'atom_to_list' + (%% Line 252 + Atom) + in let <_5> = + [45|_4] + in %% Line 252 + apply 'build_commands2'/2 + (T, [_5|A]) + %% Line 253 + <[{'args',L}|T],A> when 'true' -> + let <_6> = + apply %% Line 254 + 'concat_args'/1 + (%% Line 254 + L) + in %% Line 254 + apply 'build_commands2'/2 + (T, [_6|[[45|[97|[114|[103|[115]]]]]|A]]) + %% Line 255 + <[{Atom,Value}|T],A> when 'true' -> + let <_7> = + call %% Line 256 + 'erlang':%% Line 256 + 'atom_to_list' + (%% Line 256 + Atom) + in let <_8> = + [45|_7] + in %% Line 256 + apply 'build_commands2'/2 + (T, [Value|[_8|A]]) + ( <_10,_9> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_10,_9}) + -| [{'function_name',{'build_commands2',2}}] ) + -| ['compiler_generated'] ) + end +'concat_args'/1 = + %% Line 258 + fun (_0) -> + case _0 of + <[H|T]> when 'true' -> + let <_1> = + apply %% Line 259 + 'concat_args2'/1 + (%% Line 259 + T) + in %% Line 259 + call 'erlang':'++' + (H, _1) + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'concat_args',1}}] ) + -| ['compiler_generated'] ) + end +'concat_args2'/1 = + %% Line 260 + fun (_0) -> + case _0 of + <[]> when 'true' -> + %% Line 261 + [] + %% Line 262 + <[H|T]> when 'true' -> + let <_1> = + apply %% Line 263 + 'concat_args2'/1 + (%% Line 263 + T) + in let <_2> = + call %% Line 263 + 'erlang':%% Line 263 + '++' + (%% Line 263 + H, _1) + in %% Line 263 + [32|_2] + ( <_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3}) + -| [{'function_name',{'concat_args2',1}}] ) + -| ['compiler_generated'] ) + end +'new_service'/3 = + %% Line 266 + fun (_0,_1,_2) -> + %% Line 267 + apply 'new_service'/4 + (_0, _1, _2, []) +'new_service'/4 = + %% Line 268 + fun (_0,_1,_2,_3) -> + let = + call %% Line 269 + 'lists':%% Line 269 + 'keydelete' + (%% Line 269 + 'internalservicename', %% Line 269 + 1, _1) + in let = + call %% Line 272 + 'lists':%% Line 272 + 'keyreplace' + (%% Line 272 + 'servicename', %% Line 272 + 1, %% Line 272 + Tmp0, %% Line 273 + {'servicename',_0}) + in let <_8> = + case %% Line 274 + call 'lists':'keysearch' + ('env', 1, Tmp1) of + %% Line 275 + <{'value',{'env',Env0}}> when 'true' -> + let = + call %% Line 276 + 'lists':%% Line 276 + 'keydelete' + (%% Line 276 + [69|[82|[76|[83|[82|[86|[95|[83|[69|[82|[86|[73|[67|[69|[95|[78|[65|[77|[69]]]]]]]]]]]]]]]]]]], %% Line 276 + 1, %% Line 276 + Env0) + in %% Line 277 + call 'lists':'keyreplace' + ('env', 1, Tmp1, %% Line 278 + {'env',[{[69|[82|[76|[83|[82|[86|[95|[83|[69|[82|[86|[73|[67|[69|[95|[78|[65|[77|[69]]]]]]]]]]]]]]]]]]],_3}|%% Line 280 + Env1]}) + %% Line 281 + <_42> when 'true' -> + %% Line 282 + Tmp1 + end + in let <_11> = + case %% Line 285 + call 'lists':'keysearch' + ('args', 1, _8) of + %% Line 286 + <'false'> when 'true' -> + %% Line 287 + [] + %% Line 288 + <{'value',{'args',OldArgs}}> when 'true' -> + %% Line 289 + OldArgs + ( <_10> when 'true' -> + %% Line 285 + primop 'match_fail' + ({'case_clause',_10}) + -| ['compiler_generated'] ) + end + in let = + apply %% Line 291 + 'backstrip'/2 + (_11, %% Line 291 + [43|[43]]) + in let <_19> = + fun (_16,_15) -> + %% Line 292 + case <_16,_15> of + when 'true' -> + %% Line 293 + case of + %% Line 294 + <( 'true' + -| ['compiler_generated'] ),_43> when 'true' -> + _@r0 + %% Line 295 + <'false',[43|[43]]> when 'true' -> + {'true',AccIn} + %% Line 296 + <( _51 + -| ['compiler_generated'] ),( _52 + -| ['compiler_generated'] )> when 'true' -> + {'false',[A|AccIn]} + end + ( <_18,_17> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_18,_17}) + -| [{'function_name',{'-new_service/4-fun-0-',2}}] ) + -| ['compiler_generated'] ) + end + in %% Line 292 + case call 'lists':'foldr' + (_19, %% Line 298 + {'false',[]}, %% Line 298 + Args) of + <{Found,Tail}> when 'true' -> + let <_22> = + case %% Line 300 + Found of + %% Line 301 + <'true'> when 'true' -> + %% Line 302 + apply 'check_tail'/1 + (Tail) + %% Line 303 + <'false'> when 'true' -> + %% Line 304 + {[],'false'} + ( <_21> when 'true' -> + %% Line 300 + primop 'match_fail' + ({'case_clause',_21}) + -| ['compiler_generated'] ) + end + in %% Line 300 + case _22 of + <{OtherFlags,_X_DataDir}> when 'true' -> + let <_25> = + case _2 of + %% Line 307 + <[]> when 'true' -> + %% Line 308 + OtherFlags + %% Line 309 + <_45> when 'true' -> + %% Line 310 + [[45|[100|[97|[116|[97]]]]]|[_2|OtherFlags]] + end + in %% Line 312 + case Found of + %% Line 313 + <'false'> when 'true' -> + let <_28> = + case _25 of + %% Line 315 + <[]> when 'true' -> + %% Line 316 + [] + %% Line 317 + <_46> when 'true' -> + %% Line 318 + [[43|[43]]|_25] + end + in %% Line 320 + case of + %% Line 321 + <[],[]> when 'true' -> + _8 + %% Line 323 + <( [] + -| ['compiler_generated'] ),_47> when 'true' -> + %% Line 324 + call 'erlang':'++' + (_8, [{'args',_28}|[]]) + %% Line 325 + <_48,_49> when 'true' -> + let <_30> = + call %% Line 326 + 'erlang':%% Line 326 + '++' + (%% Line 326 + Args, _28) + in %% Line 326 + call 'lists':'keyreplace' + ('args', 1, _8, {'args',_30}) + end + %% Line 328 + <'true'> when 'true' -> + let = + apply %% Line 329 + 'backstrip'/2 + (%% Line 329 + Args, %% Line 329 + [[43|[43]]|Tail]) + in let <_34> = + case _25 of + %% Line 331 + <[]> when 'true' -> + %% Line 332 + [] + %% Line 333 + <_50> when 'true' -> + %% Line 334 + [[43|[43]]|_25] + end + in let = + call %% Line 336 + 'erlang':%% Line 336 + '++' + (%% Line 336 + StripArgs, _34) + in %% Line 337 + call 'lists':'keyreplace' + ('args', 1, _8, {'args',NewArgs}) + ( <_37> when 'true' -> + primop 'match_fail' + ({'case_clause',_37}) + -| ['compiler_generated'] ) + end + ( <_23> when 'true' -> + primop 'match_fail' + ({'badmatch',_23}) + -| ['compiler_generated'] ) + end + ( <_20> when 'true' -> + primop 'match_fail' + ({'badmatch',_20}) + -| ['compiler_generated'] ) + end +'backstrip'/2 = + %% Line 341 + fun (_0,_1) -> + let <_3> = + call %% Line 342 + 'lists':%% Line 342 + 'reverse' + (_0) + in let <_2> = + call %% Line 342 + 'lists':%% Line 342 + 'reverse' + (_1) + in let <_4> = + apply %% Line 342 + 'backstrip2'/2 + (_3, _2) + in %% Line 342 + call 'lists':'reverse' + (_4) +'backstrip2'/2 = + %% Line 343 + fun (_0,_1) -> + case <_0,_1> of + <[A|T1],[_4|T2]> + when call 'erlang':'=:=' + (_4, + A) -> + %% Line 344 + apply 'backstrip2'/2 + (T1, T2) + %% Line 345 + when 'true' -> + %% Line 346 + L + end +'check_tail'/1 = + %% Line 348 + fun (_0) -> + %% Line 349 + case apply 'check_tail'/3 + (_0, [], 'false') of + <{A,B}> when 'true' -> + let <_2> = + call %% Line 350 + 'lists':%% Line 350 + 'reverse' + (%% Line 350 + A) + in %% Line 350 + {_2,B} + ( <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + -| ['compiler_generated'] ) + end +'check_tail'/3 = + %% Line 352 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <[],OtherFlags,DataDir> when 'true' -> + %% Line 353 + {OtherFlags,DataDir} + %% Line 354 + <[[45|[100|[97|[116|[97]]]]]|[TheDataDir|T]],OtherFlags,_X_DataDir> when 'true' -> + %% Line 355 + apply 'check_tail'/3 + (T, OtherFlags, TheDataDir) + %% Line 356 + <[H|T],OtherFlags,DataDir> when 'true' -> + %% Line 357 + apply 'check_tail'/3 + (T, [H|OtherFlags], DataDir) + ( <_5,_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4,_3}) + -| [{'function_name',{'check_tail',3}}] ) + -| ['compiler_generated'] ) + end +'split_arglist'/1 = + %% Line 363 + fun (_0) -> + case _0 of + <[]> when 'true' -> + %% Line 364 + [] + %% Line 365 + <[{'args',Str}|T]> when 'true' -> + let <_1> = + apply %% Line 366 + 'parse_arglist'/1 + (%% Line 366 + Str) + in %% Line 366 + [{'args',_1}|T] + %% Line 367 + <[H|T]> when 'true' -> + let <_2> = + apply %% Line 368 + 'split_arglist'/1 + (%% Line 368 + T) + in %% Line 368 + [H|_2] + ( <_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3}) + -| [{'function_name',{'split_arglist',1}}] ) + -| ['compiler_generated'] ) + end +'parse_arglist'/1 = + %% Line 371 + fun (_0) -> + let <_1> = + apply %% Line 372 + 'parse_arglist'/2 + (_0, %% Line 372 + []) + in %% Line 372 + call 'lists':'reverse' + (_1) +'parse_arglist'/2 = + %% Line 373 + fun (_0,_1) -> + let = + call %% Line 374 + 'string':%% Line 374 + 'trim' + (_0, %% Line 374 + 'leading') + in %% Line 375 + case call 'erlang':'length' + (Stripped) of + %% Line 376 + <0> when 'true' -> + _1 + %% Line 378 + <_7> when 'true' -> + %% Line 379 + case apply 'pick_argument'/1 + (_0) of + <{Next,Rest}> when 'true' -> + %% Line 380 + apply 'parse_arglist'/2 + (Rest, [Next|_1]) + ( <_3> when 'true' -> + primop 'match_fail' + ({'badmatch',_3}) + -| ['compiler_generated'] ) + end + end +'pick_argument'/1 = + %% Line 383 + fun (_0) -> + %% Line 384 + case apply 'pick_argument'/3 + ('normal', _0, []) of + <{Rev,Rest}> when 'true' -> + let <_2> = + call %% Line 385 + 'lists':%% Line 385 + 'reverse' + (%% Line 385 + Rev) + in %% Line 385 + {_2,Rest} + ( <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + -| ['compiler_generated'] ) + end +'pick_argument'/3 = + %% Line 387 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <_6,[],Acc> when 'true' -> + %% Line 388 + {Acc,[]} + %% Line 389 + <'normal',[32|T],Acc> when 'true' -> + %% Line 390 + {Acc,T} + %% Line 391 + <'normal',[92|T],Acc> when 'true' -> + %% Line 392 + apply 'pick_argument'/3 + ('normal_escaped', T, [92|Acc]) + %% Line 393 + <'normal',[34|T],Acc> when 'true' -> + %% Line 394 + apply 'pick_argument'/3 + ('quoted', T, [34|Acc]) + %% Line 395 + <'normal_escaped',[34|T],Acc> when 'true' -> + %% Line 396 + apply 'pick_argument'/3 + ('bquoted', T, [34|Acc]) + %% Line 397 + <'normal_escaped',[A|T],Acc> when 'true' -> + %% Line 398 + apply 'pick_argument'/3 + ('normal', T, [A|Acc]) + %% Line 399 + <'quoted_escaped',[H|T],Acc> when 'true' -> + %% Line 400 + apply 'pick_argument'/3 + ('quoted', T, [H|Acc]) + %% Line 401 + <'quoted',[34|T],Acc> when 'true' -> + %% Line 402 + apply 'pick_argument'/3 + ('normal', T, [34|Acc]) + %% Line 403 + <'quoted',[92|T],Acc> when 'true' -> + %% Line 404 + apply 'pick_argument'/3 + ('quoted_escaped', T, [92|Acc]) + %% Line 405 + <'quoted',[H|T],Acc> when 'true' -> + %% Line 406 + apply 'pick_argument'/3 + ('quoted', T, [H|Acc]) + %% Line 407 + <'bquoted_escaped',[34|T],Acc> when 'true' -> + %% Line 408 + apply 'pick_argument'/3 + ('normal', T, [34|Acc]) + %% Line 409 + <'bquoted_escaped',[H|T],Acc> when 'true' -> + %% Line 410 + apply 'pick_argument'/3 + ('bquoted', T, [H|Acc]) + %% Line 411 + <'bquoted',[92|T],Acc> when 'true' -> + %% Line 412 + apply 'pick_argument'/3 + ('bquoted_escaped', T, [92|Acc]) + %% Line 413 + <'bquoted',[H|T],Acc> when 'true' -> + %% Line 414 + apply 'pick_argument'/3 + ('bquoted', T, [H|Acc]) + %% Line 415 + <'normal',[H|T],Acc> when 'true' -> + %% Line 416 + apply 'pick_argument'/3 + ('normal', T, [H|Acc]) + ( <_5,_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4,_3}) + -| [{'function_name',{'pick_argument',3}}] ) + -| ['compiler_generated'] ) + end +'split_helper'/2 = + %% Line 418 + fun (_0,_1) -> + case <_0,_1> of + <[69|[110|[118|[58]]]],{Where,0}> when 'true' -> + let <_2> = + call %% Line 419 + 'erlang':%% Line 419 + '+' + (%% Line 419 + Where, %% Line 419 + 1) + in %% Line 419 + {_2,Where} + %% Line 420 + <_6,{Where,Pos}> when 'true' -> + let <_3> = + call %% Line 421 + 'erlang':%% Line 421 + '+' + (%% Line 421 + Where, %% Line 421 + 1) + in %% Line 421 + {_3,Pos} + ( <_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4}) + -| [{'function_name',{'split_helper',2}}] ) + -| ['compiler_generated'] ) + end +'split_by_env'/1 = + %% Line 423 + fun (_0) -> + let <_1> = 'split_helper'/2 + in %% Line 425 + case call 'lists':'foldl' + (_1, {0,0}, _0) of + %% Line 426 + <{_7,0}> when 'true' -> + %% Line 428 + {_0,[]} + %% Line 429 + <{Len,Pos}> when 'true' -> + let <_4> = + call %% Line 430 + 'lists':%% Line 430 + 'sublist' + (_0, %% Line 430 + Pos) + in let <_2> = + call %% Line 430 + 'erlang':%% Line 430 + '+' + (%% Line 430 + Pos, %% Line 430 + 2) + in let <_3> = + call %% Line 430 + 'lists':%% Line 430 + 'sublist' + (_0, _2, %% Line 430 + Len) + in %% Line 430 + {_4,_3} + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end +'splitline'/1 = + %% Line 434 + fun (_0) -> + %% Line 435 + case call 'string':'split' + (_0, [58]) of + %% Line 436 + <[_4|[]]> when 'true' -> + %% Line 437 + {_0,[]} + %% Line 438 + <[N|[V|[]]]> when 'true' -> + let <_1> = + call %% Line 439 + 'string':%% Line 439 + 'slice' + (%% Line 439 + V, %% Line 439 + 1) + in %% Line 439 + {N,_1} + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('erlsrv') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('erlsrv', _0) +end \ No newline at end of file diff --git a/test/data/sasl/format_lib_supp.core b/test/data/sasl/format_lib_supp.core new file mode 100644 index 0000000..5c86d93 --- /dev/null +++ b/test/data/sasl/format_lib_supp.core @@ -0,0 +1,369 @@ +module 'format_lib_supp' ['module_info'/0, + 'module_info'/1, + 'print_info'/2, + 'print_info'/3] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[102|[111|[114|[109|[97|[116|[95|[108|[105|[98|[95|[115|[117|[112|[112|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]]]],1}]] +'print_info'/2 = + %% Line 52 + fun (_0,_1) -> + %% Line 53 + apply 'print_info'/3 + (_0, 79, _1) +'print_info'/3 = + %% Line 54 + fun (_0,_1,_2) -> + do %% Line 55 + apply 'print_header'/3 + (_0, _1, _2) + %% Line 56 + apply 'print_format'/3 + (_0, _1, _2) +'print_header'/3 = + %% Line 58 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 59 + apply 'print_header2'/3 + (Device, Line, Header) + %% Line 60 + when 'true' -> + %% Line 61 + apply 'print_header2'/3 + (Device, Line, []) + end +'print_header2'/3 = + %% Line 62 + fun (_0,_1,_2) -> + let = + call %% Line 63 + 'lists':%% Line 63 + 'concat' + (%% Line 63 + [[126|[110|[126]]]|[_1|[[46]|[_1|[[115|[126|[110]]]]]]]]) + in let = + call %% Line 64 + 'lists':%% Line 64 + 'concat' + (%% Line 64 + [[126]|[_1|[[99|[126|[110]]]]]]) + in do %% Line 65 + call 'io':'format' + (_0, Format1, [_2|[]]) + %% Line 66 + call 'io':'format' + (_0, Format2, [61]) +'print_format'/3 = + %% Line 68 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 69 + call 'io':'format' + (Device, '~n', []) + %% Line 70 + when 'true' -> + do %% Line 71 + apply 'print_data'/3 + (Device, Line, Data) + %% Line 72 + apply 'print_format'/3 + (Device, Line, T) + %% Line 73 + when 'true' -> + do %% Line 74 + apply 'print_items'/3 + (Device, Line, Items) + %% Line 75 + apply 'print_format'/3 + (Device, Line, T) + %% Line 76 + when 'true' -> + do %% Line 77 + apply 'print_newlines'/2 + (Device, N) + %% Line 78 + apply 'print_format'/3 + (Device, Line, T) + %% Line 79 + when 'true' -> + %% Line 80 + apply 'print_format'/3 + (Device, Line, T) + ( <_5,_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4,_3}) + -| [{'function_name',{'print_format',3}}] ) + -| ['compiler_generated'] ) + end +'print_data'/3 = + %% Line 82 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <_X_Device,_X_Line,[]> when 'true' -> + 'ok' + %% Line 83 + when 'true' -> + do %% Line 84 + apply 'print_one_line'/4 + (Device, Line, Key, Value) + %% Line 85 + apply 'print_data'/3 + (Device, Line, T) + %% Line 86 + when 'true' -> + let = + call %% Line 87 + 'misc_supp':%% Line 87 + 'modifier' + (%% Line 87 + Device) + in let <_4> = + call %% Line 88 + 'erlang':%% Line 88 + '++' + (%% Line 88 + Modifier, %% Line 88 + [112|[126|[110]]]) + in let <_5> = + [126|_4] + in do %% Line 88 + call 'io':'format' + (Device, _5, [Value|[]]) + %% Line 89 + apply 'print_data'/3 + (Device, Line, T) + %% Line 90 + when 'true' -> + let = + call %% Line 91 + 'misc_supp':%% Line 91 + 'modifier' + (%% Line 91 + Device) + in let <_7> = + call %% Line 92 + 'erlang':%% Line 92 + '++' + (%% Line 92 + Modifier, %% Line 92 + [112|[126|[110]]]) + in let <_8> = + [126|_7] + in %% Line 92 + call 'io':'format' + (Device, _8, [Value|[]]) + end +'print_items'/3 = + %% Line 94 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 95 + apply 'print_items'/4 + (Device, Line, Name, Items) + ( <_5,_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4,_3}) + -| [{'function_name',{'print_items',3}}] ) + -| ['compiler_generated'] ) + end +'print_newlines'/2 = + %% Line 97 + fun (_0,_1) -> + case <_0,_1> of + <_X_Device,0> when 'true' -> + 'ok' + %% Line 98 + + when call 'erlang':'>' + (N, + 0) -> + do %% Line 99 + call 'io':'format' + (Device, '~n', []) + let <_2> = + call %% Line 100 + 'erlang':%% Line 100 + '-' + (%% Line 100 + N, %% Line 100 + 1) + in %% Line 100 + apply 'print_newlines'/2 + (Device, _2) + ( <_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_4,_3}) + -| [{'function_name',{'print_newlines',2}}] ) + -| ['compiler_generated'] ) + end +'print_one_line'/4 = + %% Line 102 + fun (_0,_1,_2,_3) -> + let = + call %% Line 103 + 'misc_supp':%% Line 103 + 'modifier' + (_0) + in let = + apply %% Line 104 + 'term_to_string'/2 + (_2, %% Line 104 + Modifier) + in let <_6> = + call %% Line 105 + 'string':%% Line 105 + 'length' + (%% Line 105 + StrKey) + in let = + call %% Line 105 + 'lists':%% Line 105 + 'min' + (%% Line 105 + [_6|[_1|[]]]) + in let = + call %% Line 106 + 'erlang':%% Line 106 + '-' + (_1, %% Line 106 + KeyLen) + in let = + call %% Line 107 + 'lists':%% Line 107 + 'concat' + (%% Line 107 + [[126|[45]]|[KeyLen|[Modifier|[[115]]]]]) + in let = + call %% Line 108 + 'lists':%% Line 108 + 'concat' + (%% Line 108 + [[126]|[ValueLen|[Modifier|[[115|[126|[110]]]]]]]) + in do %% Line 109 + call 'io':'format' + (_0, Format1, [StrKey|[]]) + let = + apply %% Line 110 + 'term_to_string'/2 + (_3, %% Line 110 + Modifier) + in let = + call %% Line 111 + 'string':%% Line 111 + 'length' + (%% Line 111 + Try) + in %% Line 112 + case <> of + %% Line 113 + <> + when call 'erlang':'<' + (Length, + ValueLen) -> + %% Line 114 + call 'io':'format' + (_0, Format2, [Try|[]]) + %% Line 115 + <> when 'true' -> + do %% Line 116 + call 'io':'format' + (_0, [126|[110|[32|[32|[32|[32|[32|[32|[32|[32|[32]]]]]]]]]]], []) + let = + call %% Line 117 + 'lists':%% Line 117 + 'concat' + (%% Line 117 + [[126]|[_1|[[46|[57]]|[Modifier|[[112|[126|[110]]]]]]]]) + in %% Line 118 + call 'io':'format' + (_0, Format3, [_3|[]]) + end +'term_to_string'/2 = + %% Line 121 + fun (_0,_1) -> + let <_2> = + apply %% Line 122 + 'get_format'/2 + (_0, _1) + in %% Line 122 + call 'io_lib':'format' + (_2, [_0|[]]) +'get_format'/2 = + %% Line 124 + fun (_0,_1) -> + case <_0,_1> of + <[],_7> when 'true' -> + %% Line 125 + [126|[112]] + %% Line 126 + when 'true' -> + %% Line 127 + case call 'io_lib':'printable_list' + (Value) of + %% Line 128 + <'true'> when 'true' -> + let <_2> = + call 'erlang':'++' + (Modifier, [115]) + in [126|_2] + %% Line 129 + <'false'> when 'true' -> + let <_3> = + call 'erlang':'++' + (Modifier, [112]) + in [126|_3] + ( <_4> when 'true' -> + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end + end +'print_items'/4 = + %% Line 135 + fun (_0,_1,_2,_3) -> + do %% Line 136 + apply 'print_one_line'/4 + (_0, _1, _2, [32]) + %% Line 137 + apply 'print_item_elements'/3 + (_0, _1, _3) +'print_item_elements'/3 = + %% Line 139 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <_X_Device,_X_Line,[]> when 'true' -> + 'ok' + %% Line 140 + when 'true' -> + let <_3> = + call %% Line 141 + 'lists':%% Line 141 + 'concat' + (%% Line 141 + [[32|[32|[32]]]|[Key|[]]]) + in do %% Line 141 + apply 'print_one_line'/4 + (Device, Line, _3, Value) + %% Line 142 + apply 'print_item_elements'/3 + (Device, Line, T) + ( <_6,_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5,_4}) + -| [{'function_name',{'print_item_elements',3}}] ) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('format_lib_supp') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('format_lib_supp', _0) +end \ No newline at end of file diff --git a/test/data/sasl/misc_supp.core b/test/data/sasl/misc_supp.core new file mode 100644 index 0000000..0a83bdf --- /dev/null +++ b/test/data/sasl/misc_supp.core @@ -0,0 +1,245 @@ +module 'misc_supp' ['assq'/2, + 'format_pdict'/3, + 'format_tuples'/2, + 'is_string'/1, + 'modifier'/1, + 'module_info'/0, + 'module_info'/1, + 'multi_map'/2, + 'passq'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[109|[105|[115|[99|[95|[115|[117|[112|[112|[46|[101|[114|[108]]]]]]]]]]]]]]]]],1}]] +'format_pdict'/3 = + %% Line 43 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <'normal',_X_PDict,_X_Exclude> when 'true' -> + %% Line 44 + [] + %% Line 45 + <'all',PDict,Exclude> when 'true' -> + %% Line 46 + case apply 'format_tuples'/2 + (PDict, ['$sys_dict$'|Exclude]) of + %% Line 47 + <[]> when 'true' -> + [] + %% Line 48 + when 'true' -> + [{'newline',1}|Data] + end + ( <_6,_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5,_4}) + -| [{'function_name',{'format_pdict',3}}] ) + -| ['compiler_generated'] ) + end +'format_tuples'/2 = + %% Line 56 + fun (_0,_1) -> + %% Line 57 + case apply 'format_tuples'/3 + (_0, _1, []) of + %% Line 58 + <[]> when 'true' -> + [] + %% Line 59 + when 'true' -> + [{'data',Data}|[]] + end +'format_tuples'/3 = + %% Line 61 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <[],_X_Exclude,Res> when 'true' -> + Res + %% Line 62 + <[_@r0 = {Key,Value}|T],Exclude,Res> when 'true' -> + %% Line 63 + case call 'lists':'member' + (Key, Exclude) of + %% Line 64 + <'true'> when 'true' -> + %% Line 65 + apply 'format_tuples'/3 + (T, Exclude, Res) + %% Line 66 + <'false'> when 'true' -> + %% Line 67 + apply 'format_tuples'/3 + (T, Exclude, [_@r0|Res]) + ( <_3> when 'true' -> + primop 'match_fail' + ({'case_clause',_3}) + -| ['compiler_generated'] ) + end + ( <_6,_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5,_4}) + -| [{'function_name',{'format_tuples',3}}] ) + -| ['compiler_generated'] ) + end +'assq'/2 = + %% Line 75 + fun (_0,_1) -> + %% Line 76 + case call 'lists':'keysearch' + (_0, 1, _1) of + %% Line 77 + <{'value',{_5,Val}}> + when call 'erlang':'=:=' + (_5, + _0) -> + {'value',Val} + %% Line 78 + <_6> when 'true' -> + 'false' + end +'passq'/2 = + %% Line 82 + fun (_0,_1) -> + %% Line 83 + case call 'lists':'keysearch' + (_0, 1, _1) of + %% Line 84 + <{'value',{_5,Val}}> + when call 'erlang':'=:=' + (_5, + _0) -> + Val + %% Line 85 + <_6> when 'true' -> + 'undefined' + end +'is_string'/1 = + %% Line 89 + fun (_0) -> + case _0 of + <[]> when 'true' -> + 'false' + %% Line 90 + when 'true' -> + apply 'is_string_2'/1 + (X) + end +'is_string_2'/1 = + %% Line 92 + fun (_0) -> + case _0 of + <[]> when 'true' -> + 'true' + %% Line 93 + <[H|T]> + when try + let <_1> = + call 'erlang':'is_integer' + (H) + in let <_2> = + call 'erlang':'>=' + (H, 32) + in let <_3> = + call 'erlang':'=<' + (H, 255) + in let <_4> = + call 'erlang':'and' + (_2, _3) + in call 'erlang':'and' + (_1, _4) + of -> + Try + catch -> + 'false' -> + %% Line 94 + apply 'is_string_2'/1 + (T) + %% Line 95 + <_6> when 'true' -> + 'false' + end +'multi_map'/2 = + %% Line 103 + fun (_0,_1) -> + case <_0,_1> of + <_X_Func,[[]|_X_ListOfLists]> when 'true' -> + [] + %% Line 104 + when 'true' -> + let <_4> = + fun (_2) -> + %% Line 105 + call 'erlang':'hd' + (_2) + in let <_5> = + call %% Line 105 + 'lists':%% Line 105 + 'map' + (_4, %% Line 105 + ListOfLists) + in let <_6> = + call %% Line 105 + 'erlang':%% Line 105 + 'apply' + (%% Line 105 + Func, _5) + in let <_9> = + fun (_7) -> + %% Line 107 + call 'erlang':'tl' + (_7) + in let <_10> = + call %% Line 107 + 'lists':%% Line 107 + 'map' + (_9, %% Line 107 + ListOfLists) + in let <_11> = + apply %% Line 106 + 'multi_map'/2 + (%% Line 106 + Func, _10) + in %% Line 105 + [_6|_11] + end +'modifier'/1 = + %% Line 112 + fun (_0) -> + let <_2> = + case %% Line 114 + call 'io':'getopts' + (_0) of + %% Line 115 + + when call 'erlang':'is_list' + (List) -> + %% Line 116 + call 'proplists':'get_value' + ('encoding', List, 'latin1') + %% Line 117 + <_5> when 'true' -> + %% Line 118 + 'latin1' + end + in %% Line 120 + apply 'encoding_to_modifier'/1 + (_2) +'encoding_to_modifier'/1 = + %% Line 122 + fun (_0) -> + case _0 of + <'latin1'> when 'true' -> + [] + %% Line 123 + <_2> when 'true' -> + [116] + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('misc_supp') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('misc_supp', _0) +end \ No newline at end of file diff --git a/test/data/sasl/rb.core b/test/data/sasl/rb.core new file mode 100644 index 0000000..470299e --- /dev/null +++ b/test/data/sasl/rb.core @@ -0,0 +1,3167 @@ +module 'rb' ['code_change'/3, + 'filter'/1, + 'filter'/2, + 'grep'/1, + 'h'/0, + 'handle_call'/3, + 'handle_cast'/2, + 'handle_info'/2, + 'help'/0, + 'init'/1, + 'list'/0, + 'list'/1, + 'log_list'/0, + 'log_list'/1, + 'module_info'/0, + 'module_info'/1, + 'rescan'/0, + 'rescan'/1, + 'show'/0, + 'show'/1, + 'start'/0, + 'start'/1, + 'start_link'/1, + 'start_log'/1, + 'stop'/0, + 'stop_log'/0, + 'terminate'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[114|[98|[46|[101|[114|[108]]]]]]]]]],1}], + %% Line 22 + 'behaviour' = + %% Line 22 + ['gen_server'], + %% Line 41 + 'record' = + %% Line 41 + [{'state',[{'record_field',41,{'atom',41,'dir'}}|[{'record_field',41,{'atom',41,'data'}}|[{'record_field',41,{'atom',41,'device'}}|[{'record_field',41,{'atom',41,'max'}}|[{'record_field',41,{'atom',41,'type'}}|[{'record_field',41,{'atom',41,'abort'}}|[{'record_field',41,{'atom',41,'log'}}]]]]]]]}]] +'start'/0 = + %% Line 47 + fun () -> + apply 'start'/1 + ([]) +'start'/1 = + %% Line 48 + fun (_0) -> + %% Line 49 + call 'supervisor':'start_child' + ('sasl_sup', %% Line 50 + {'rb_server',{'rb','start_link',[_0|[]]},%% Line 51 + 'temporary',%% Line 51 + 'brutal_kill',%% Line 51 + 'worker',%% Line 51 + ['rb']}) +'start_link'/1 = + %% Line 53 + fun (_0) -> + %% Line 54 + call 'gen_server':'start_link' + ({'local','rb_server'}, 'rb', _0, []) +'stop'/0 = + %% Line 56 + fun () -> + %% Line 57 + call 'supervisor':'terminate_child' + ('sasl_sup', 'rb_server') +'rescan'/0 = + %% Line 59 + fun () -> + apply 'rescan'/1 + ([]) +'rescan'/1 = + %% Line 60 + fun (_0) -> + %% Line 61 + apply 'call'/1 + ({'rescan',_0}) +'list'/0 = + %% Line 63 + fun () -> + apply 'list'/1 + ('all') +'list'/1 = + %% Line 64 + fun (_0) -> + apply 'call'/1 + ({'list',_0}) +'log_list'/0 = + %% Line 66 + fun () -> + apply 'log_list'/1 + ('all') +'log_list'/1 = + %% Line 67 + fun (_0) -> + apply 'call'/1 + ({'log_list',_0}) +'show'/0 = + %% Line 69 + fun () -> + %% Line 70 + apply 'call'/1 + ('show') +'show'/1 = + %% Line 72 + fun (_0) -> + case _0 of + + when call 'erlang':'is_integer' + (_0) -> + %% Line 73 + apply 'call'/1 + ({'show_number',Number}) + %% Line 74 + + when call 'erlang':'is_atom' + (_0) -> + %% Line 75 + apply 'call'/1 + ({'show_type',Type}) + ( <_1> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_1}) + -| [{'function_name',{'show',1}}] ) + -| ['compiler_generated'] ) + end +'grep'/1 = + %% Line 77 + fun (_0) -> + apply 'call'/1 + ({'grep',_0}) +'filter'/1 = + %% Line 79 + fun (_0) -> + case _0 of + + when call 'erlang':'is_list' + (_0) -> + %% Line 80 + apply 'call'/1 + ({'filter',Filters}) + ( <_1> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_1}) + -| [{'function_name',{'filter',1}}] ) + -| ['compiler_generated'] ) + end +'filter'/2 = + %% Line 82 + fun (_0,_1) -> + case <_0,_1> of + + when try + ( let <_4> = + case call 'erlang':'is_list' + (Filters) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'is_tuple' + (FDates) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_2> when 'true' -> + _2 + -| ['compiler_generated'] ) + end + in ( call 'erlang':'=:=' + (( _4 + -| ['compiler_generated'] ), 'true') + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' -> + %% Line 83 + apply 'call'/1 + ({'filter',{Filters,FDates}}) + ( <_6,_5> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5}) + -| [{'function_name',{'filter',2}}] ) + -| ['compiler_generated'] ) + end +'start_log'/1 = + %% Line 85 + fun (_0) -> + apply 'call'/1 + ({'start_log',_0}) +'stop_log'/0 = + %% Line 87 + fun () -> + apply 'call'/1 + ('stop_log') +'h'/0 = + %% Line 89 + fun () -> + apply 'help'/0 + () +'help'/0 = + %% Line 90 + fun () -> + do %% Line 91 + call 'io':'format' + ([126|[110|[82|[101|[112|[111|[114|[116|[32|[66|[114|[111|[119|[115|[101|[114|[32|[84|[111|[111|[108|[32|[45|[32|[117|[115|[97|[103|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 92 + call 'io':'format' + ([61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[61|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 93 + call 'io':'format' + ([114|[98|[58|[115|[116|[97|[114|[116|[40|[41|[32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[115|[116|[97|[114|[116|[32|[116|[104|[101|[32|[114|[98|[95|[115|[101|[114|[118|[101|[114|[32|[119|[105|[116|[104|[32|[100|[101|[102|[97|[117|[108|[116|[32|[111|[112|[116|[105|[111|[110|[115|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 94 + call 'io':'format' + ([114|[98|[58|[115|[116|[97|[114|[116|[40|[79|[112|[116|[105|[111|[110|[115|[41|[32|[32|[45|[32|[119|[104|[101|[114|[101|[32|[79|[112|[116|[105|[111|[110|[115|[32|[105|[115|[32|[97|[32|[108|[105|[115|[116|[32|[111|[102|[58|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 95 + apply 'print_options'/0 + () + do %% Line 96 + call 'io':'format' + ([114|[98|[58|[104|[40|[41|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[112|[114|[105|[110|[116|[32|[116|[104|[105|[115|[32|[104|[101|[108|[112|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 97 + call 'io':'format' + ([114|[98|[58|[104|[101|[108|[112|[40|[41|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[112|[114|[105|[110|[116|[32|[116|[104|[105|[115|[32|[104|[101|[108|[112|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 98 + call 'io':'format' + ([114|[98|[58|[108|[105|[115|[116|[40|[41|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[108|[105|[115|[116|[32|[97|[108|[108|[32|[114|[101|[112|[111|[114|[116|[115|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 99 + call 'io':'format' + ([114|[98|[58|[108|[105|[115|[116|[40|[84|[121|[112|[101|[41|[32|[32|[32|[32|[32|[32|[45|[32|[108|[105|[115|[116|[32|[97|[108|[108|[32|[114|[101|[112|[111|[114|[116|[115|[32|[111|[102|[32|[116|[121|[112|[101|[32|[84|[121|[112|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 100 + call 'io':'format' + ([114|[98|[58|[108|[111|[103|[95|[108|[105|[115|[116|[40|[41|[32|[32|[32|[32|[32|[32|[45|[32|[108|[111|[103|[32|[108|[105|[115|[116|[32|[111|[102|[32|[97|[108|[108|[32|[114|[101|[112|[111|[114|[116|[115|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 101 + call 'io':'format' + ([114|[98|[58|[108|[111|[103|[95|[108|[105|[115|[116|[40|[84|[121|[112|[101|[41|[32|[32|[45|[32|[108|[111|[103|[32|[108|[105|[115|[116|[32|[111|[102|[32|[97|[108|[108|[32|[114|[101|[112|[111|[114|[116|[115|[32|[111|[102|[32|[116|[121|[112|[101|[32|[84|[121|[112|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 102 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[99|[117|[114|[114|[101|[110|[116|[108|[121|[32|[115|[117|[112|[112|[111|[114|[116|[101|[100|[32|[116|[121|[112|[101|[115|[32|[97|[114|[101|[58|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 103 + apply 'print_types'/0 + () + do %% Line 104 + call 'io':'format' + ([114|[98|[58|[103|[114|[101|[112|[40|[82|[101|[103|[69|[120|[112|[41|[32|[32|[32|[32|[32|[32|[45|[32|[112|[114|[105|[110|[116|[32|[114|[101|[112|[111|[114|[116|[115|[32|[99|[111|[110|[116|[97|[105|[110|[105|[110|[103|[32|[82|[101|[103|[69|[120|[112|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 105 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[82|[101|[103|[69|[120|[112|[32|[109|[117|[115|[116|[32|[98|[101|[32|[97|[32|[118|[97|[108|[105|[100|[32|[97|[114|[103|[117|[109|[101|[110|[116|[32|[102|[111|[114|[32|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 106 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[116|[104|[101|[32|[102|[117|[110|[99|[116|[105|[111|[110|[32|[114|[101|[58|[114|[117|[110|[47|[50|[32|[111|[114|[32|[114|[101|[58|[114|[117|[110|[47|[51|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 107 + call 'io':'format' + ([114|[98|[58|[102|[105|[108|[116|[101|[114|[40|[70|[105|[108|[116|[101|[114|[115|[41|[32|[45|[32|[112|[114|[105|[110|[116|[32|[114|[101|[112|[111|[114|[116|[115|[32|[109|[97|[116|[99|[104|[105|[110|[103|[32|[70|[105|[108|[116|[101|[114|[115|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 108 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[114|[101|[112|[111|[114|[116|[115|[32|[109|[117|[115|[116|[32|[98|[101|[32|[112|[114|[111|[112|[108|[105|[115|[116|[115|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 109 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[70|[105|[108|[116|[101|[114|[115|[32|[105|[115|[32|[97|[32|[108|[105|[115|[116|[32|[111|[102|[32|[116|[117|[112|[108|[101|[115|[32|[111|[102|[32|[116|[104|[101|[32|[102|[111|[108|[108|[111|[119|[105|[110|[103|[32|[102|[111|[114|[109|[58|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 110 + apply 'print_filters'/0 + () + do %% Line 111 + call 'io':'format' + ([114|[98|[58|[102|[105|[108|[116|[101|[114|[40|[70|[105|[108|[116|[101|[114|[115|[44|[32|[68|[97|[116|[101|[115|[41|[32|[32|[45|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 112 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[115|[97|[109|[101|[32|[97|[115|[32|[114|[98|[58|[102|[105|[108|[116|[101|[114|[47|[49|[32|[98|[117|[116|[32|[97|[99|[99|[101|[112|[116|[115|[32|[100|[97|[116|[101|[32|[114|[97|[110|[103|[101|[115|[32|[116|[111|[32|[102|[105|[108|[116|[101|[114|[32|[114|[101|[112|[111|[114|[116|[115|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 113 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[68|[97|[116|[101|[115|[32|[109|[117|[115|[116|[32|[98|[101|[32|[111|[102|[32|[116|[104|[101|[32|[102|[111|[108|[108|[111|[119|[105|[110|[103|[32|[102|[111|[114|[109|[58|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 114 + apply 'print_dates'/0 + () + do %% Line 115 + call 'io':'format' + ([114|[98|[58|[114|[101|[115|[99|[97|[110|[40|[41|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[114|[101|[115|[99|[97|[110|[115|[32|[116|[104|[101|[32|[114|[101|[112|[111|[114|[116|[32|[100|[105|[114|[101|[99|[116|[111|[114|[121|[32|[119|[105|[116|[104|[32|[115|[97|[109|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 116 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[111|[112|[116|[105|[111|[110|[115|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 117 + call 'io':'format' + ([114|[98|[58|[114|[101|[115|[99|[97|[110|[40|[79|[112|[116|[105|[111|[110|[115|[41|[32|[45|[32|[114|[101|[115|[99|[97|[110|[115|[32|[116|[104|[101|[32|[114|[101|[112|[111|[114|[116|[32|[100|[105|[114|[101|[99|[116|[111|[114|[121|[32|[119|[105|[116|[104|[32|[110|[101|[119|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 118 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[111|[112|[116|[105|[111|[110|[115|[46|[32|[79|[112|[116|[105|[111|[110|[115|[32|[105|[115|[32|[115|[97|[109|[101|[32|[97|[115|[32|[105|[110|[32|[115|[116|[97|[114|[116|[47|[49|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 119 + call 'io':'format' + ([114|[98|[58|[115|[104|[111|[119|[40|[78|[117|[109|[98|[101|[114|[41|[32|[32|[32|[32|[45|[32|[112|[114|[105|[110|[116|[32|[114|[101|[112|[111|[114|[116|[32|[110|[111|[32|[78|[117|[109|[98|[101|[114|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 120 + call 'io':'format' + ([114|[98|[58|[115|[104|[111|[119|[40|[84|[121|[112|[101|[41|[32|[32|[32|[32|[32|[32|[45|[32|[112|[114|[105|[110|[116|[32|[97|[108|[108|[32|[114|[101|[112|[111|[114|[116|[115|[32|[111|[102|[32|[116|[121|[112|[101|[32|[84|[121|[112|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 121 + call 'io':'format' + ([114|[98|[58|[115|[104|[111|[119|[40|[41|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[112|[114|[105|[110|[116|[32|[97|[108|[108|[32|[114|[101|[112|[111|[114|[116|[115|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 122 + call 'io':'format' + ([114|[98|[58|[115|[116|[97|[114|[116|[95|[108|[111|[103|[40|[70|[105|[108|[101|[41|[32|[45|[32|[114|[101|[100|[105|[114|[101|[99|[116|[32|[97|[108|[108|[32|[114|[101|[112|[111|[114|[116|[115|[32|[116|[111|[32|[102|[105|[108|[101|[32|[111|[114|[32|[105|[111|[95|[100|[101|[118|[105|[99|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 123 + call 'io':'format' + ([114|[98|[58|[115|[116|[111|[112|[95|[108|[111|[103|[40|[41|[32|[32|[32|[32|[32|[32|[45|[32|[99|[108|[111|[115|[101|[32|[116|[104|[101|[32|[108|[111|[103|[32|[102|[105|[108|[101|[32|[97|[110|[100|[32|[114|[101|[100|[105|[114|[101|[99|[116|[32|[116|[111|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 124 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[115|[116|[97|[110|[100|[97|[114|[100|[95|[105|[111|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 125 + call 'io':'format' + ([114|[98|[58|[115|[116|[111|[112|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[115|[116|[111|[112|[32|[116|[104|[101|[32|[114|[98|[95|[115|[101|[114|[118|[101|[114|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) +'call'/1 = + %% Line 134 + fun (_0) -> + %% Line 135 + call 'gen_server':'call' + ('rb_server', _0, 'infinity') +'print_options'/0 = + %% Line 140 + fun () -> + do %% Line 141 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[123|[115|[116|[97|[114|[116|[95|[108|[111|[103|[44|[32|[70|[105|[108|[101|[78|[97|[109|[101|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 142 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[100|[101|[102|[97|[117|[108|[116|[58|[32|[115|[116|[97|[110|[100|[97|[114|[100|[95|[105|[111|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 143 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[123|[109|[97|[120|[44|[32|[77|[97|[120|[78|[111|[79|[102|[82|[101|[112|[111|[114|[116|[115|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 144 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[77|[97|[120|[78|[111|[79|[102|[82|[101|[112|[111|[114|[116|[115|[32|[115|[104|[111|[117|[108|[100|[32|[98|[101|[32|[97|[110|[32|[105|[110|[116|[101|[103|[101|[114|[32|[111|[114|[32|[39|[97|[108|[108|[39|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 145 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[100|[101|[102|[97|[117|[108|[116|[58|[32|[97|[108|[108|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 146 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[123|[114|[101|[112|[111|[114|[116|[95|[100|[105|[114|[44|[32|[68|[105|[114|[83|[116|[114|[105|[110|[103|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 147 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[68|[105|[114|[83|[116|[114|[105|[110|[103|[32|[115|[104|[111|[117|[108|[100|[32|[98|[101|[32|[97|[32|[115|[116|[114|[105|[110|[103|[32|[119|[105|[116|[104|[111|[117|[116|[32|[116|[114|[97|[105|[108|[105|[110|[103|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 148 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[100|[105|[114|[101|[99|[116|[111|[114|[121|[32|[100|[101|[108|[105|[109|[105|[116|[101|[114|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 149 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[100|[101|[102|[97|[117|[108|[116|[58|[32|[123|[115|[97|[115|[108|[44|[32|[101|[114|[114|[111|[114|[95|[108|[111|[103|[103|[101|[114|[95|[109|[102|[95|[100|[105|[114|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 150 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[123|[116|[121|[112|[101|[44|[32|[82|[101|[112|[111|[114|[116|[84|[121|[112|[101|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 151 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[82|[101|[112|[111|[114|[116|[84|[121|[112|[101|[32|[115|[104|[111|[117|[108|[100|[32|[98|[101|[32|[97|[32|[115|[117|[112|[112|[111|[114|[116|[101|[100|[32|[116|[121|[112|[101|[44|[32|[39|[97|[108|[108|[39|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 152 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[111|[114|[32|[97|[32|[108|[105|[115|[116|[32|[111|[102|[32|[115|[117|[112|[112|[111|[114|[116|[101|[100|[32|[116|[121|[112|[101|[115|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 153 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[100|[101|[102|[97|[117|[108|[116|[58|[32|[97|[108|[108|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 154 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[123|[97|[98|[111|[114|[116|[95|[111|[110|[95|[101|[114|[114|[111|[114|[44|[32|[66|[111|[111|[108|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 155 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[66|[111|[111|[108|[58|[32|[116|[114|[117|[101|[32|[124|[32|[102|[97|[108|[115|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 156 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[100|[101|[102|[97|[117|[108|[116|[58|[32|[102|[97|[108|[115|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]) +'print_types'/0 = + %% Line 158 + fun () -> + do %% Line 159 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[99|[114|[97|[115|[104|[95|[114|[101|[112|[111|[114|[116|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 160 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[115|[117|[112|[101|[114|[118|[105|[115|[111|[114|[95|[114|[101|[112|[111|[114|[116|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 161 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[112|[114|[111|[103|[114|[101|[115|[115|[126|[110]]]]]]]]]]]]]]]]]]]]]) + %% Line 162 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[32|[45|[32|[101|[114|[114|[111|[114|[126|[110]]]]]]]]]]]]]]]]]]) +'print_filters'/0 = + %% Line 164 + fun () -> + do %% Line 165 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[45|[32|[123|[75|[101|[121|[44|[32|[86|[97|[108|[117|[101|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 166 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[105|[110|[99|[108|[117|[100|[101|[115|[32|[114|[101|[112|[111|[114|[116|[32|[99|[111|[110|[116|[97|[105|[110|[105|[110|[103|[32|[123|[75|[101|[121|[44|[32|[86|[97|[108|[117|[101|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 167 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[45|[32|[123|[75|[101|[121|[44|[32|[86|[97|[108|[117|[101|[44|[32|[110|[111|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 168 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[101|[120|[99|[108|[117|[100|[101|[115|[32|[114|[101|[112|[111|[114|[116|[32|[99|[111|[110|[116|[97|[105|[110|[105|[110|[103|[32|[123|[75|[101|[121|[44|[32|[86|[97|[108|[117|[101|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 169 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[45|[32|[123|[75|[101|[121|[44|[32|[82|[101|[103|[69|[120|[112|[44|[32|[114|[101|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 170 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[82|[101|[103|[69|[120|[112|[32|[109|[117|[115|[116|[32|[98|[101|[32|[97|[32|[118|[97|[108|[105|[100|[32|[97|[114|[103|[117|[109|[101|[110|[116|[32|[102|[111|[114|[32|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 171 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[116|[104|[101|[32|[102|[117|[110|[99|[116|[105|[111|[110|[32|[114|[101|[58|[114|[117|[110|[47|[50|[32|[111|[114|[32|[114|[101|[58|[114|[117|[110|[47|[51|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 172 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[45|[32|[123|[75|[101|[121|[44|[32|[82|[101|[103|[69|[120|[112|[44|[32|[114|[101|[44|[32|[110|[111|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 173 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[101|[120|[99|[108|[117|[100|[101|[115|[32|[114|[101|[112|[111|[114|[116|[32|[99|[111|[110|[116|[97|[105|[110|[105|[110|[103|[32|[123|[75|[101|[121|[44|[32|[82|[101|[103|[69|[120|[112|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) +'print_dates'/0 = + %% Line 175 + fun () -> + do %% Line 176 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[45|[32|[123|[83|[116|[97|[114|[116|[68|[97|[116|[101|[44|[32|[69|[110|[100|[68|[97|[116|[101|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 177 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[83|[116|[97|[114|[116|[68|[97|[116|[101|[32|[61|[32|[69|[110|[100|[68|[97|[116|[101|[32|[61|[32|[123|[123|[89|[44|[77|[44|[68|[125|[44|[123|[72|[44|[77|[44|[83|[125|[125|[32|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 178 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[112|[114|[105|[110|[116|[115|[32|[116|[104|[101|[32|[114|[101|[112|[111|[114|[116|[115|[32|[119|[105|[116|[104|[32|[100|[97|[116|[101|[32|[98|[101|[116|[119|[101|[101|[110|[32|[83|[116|[97|[114|[116|[68|[97|[116|[101|[32|[97|[110|[100|[32|[69|[110|[100|[68|[97|[116|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 179 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[45|[32|[123|[83|[116|[97|[114|[116|[68|[97|[116|[101|[44|[32|[102|[114|[111|[109|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 180 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[112|[114|[105|[110|[116|[115|[32|[116|[104|[101|[32|[114|[101|[112|[111|[114|[116|[115|[32|[119|[105|[116|[104|[32|[100|[97|[116|[101|[32|[103|[114|[101|[97|[116|[101|[114|[32|[116|[104|[97|[110|[32|[83|[116|[97|[114|[116|[68|[97|[116|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 181 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[45|[32|[123|[69|[110|[100|[68|[97|[116|[101|[44|[32|[116|[111|[125|[126|[110]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 182 + call 'io':'format' + ([32|[32|[32|[32|[32|[32|[32|[32|[112|[114|[105|[110|[116|[115|[32|[116|[104|[101|[32|[114|[101|[112|[111|[114|[116|[115|[32|[119|[105|[116|[104|[32|[100|[97|[116|[101|[32|[108|[101|[115|[115|[101|[114|[32|[116|[104|[97|[110|[32|[83|[116|[97|[114|[116|[68|[97|[116|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) +'init'/1 = + %% Line 184 + fun (_0) -> + do %% Line 185 + call 'erlang':'process_flag' + ('priority', 'low') + do %% Line 186 + call 'erlang':'process_flag' + ('trap_exit', 'true') + let = + apply %% Line 187 + 'get_option'/3 + (_0, %% Line 187 + 'start_log', %% Line 187 + 'standard_io') + in let = + apply %% Line 188 + 'open_log_file'/1 + (%% Line 188 + Log) + in let = + apply %% Line 189 + 'get_report_dir'/1 + (_0) + in let = + apply %% Line 190 + 'get_option'/3 + (_0, %% Line 190 + 'max', %% Line 190 + 'all') + in let = + apply %% Line 191 + 'get_option'/3 + (_0, %% Line 191 + 'type', %% Line 191 + 'all') + in let = + apply %% Line 192 + 'get_option'/3 + (_0, %% Line 192 + 'abort_on_error', %% Line 192 + 'false') + in let <_7> = + call %% Line 193 + 'erlang':%% Line 193 + '++' + (%% Line 193 + Dir, %% Line 193 + [47]) + in let = + apply %% Line 193 + 'scan_files'/3 + (_7, %% Line 193 + Max, %% Line 193 + Type) + in let <_9> = + call %% Line 194 + 'erlang':%% Line 194 + '++' + (%% Line 194 + Dir, %% Line 194 + [47]) + in %% Line 194 + {'ok',{'state',_9,Data,Device,%% Line 195 + Max,%% Line 195 + Type,%% Line 195 + Abort,%% Line 195 + Log}} +'handle_call'/3 = + %% Line 197 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <{'rescan',Options},_X_From,State> when 'true' -> + let <_224,_225> = + case %% Line 199 + apply 'get_option'/3 + (Options, 'start_log', {'undefined'}) of + %% Line 200 + <{'undefined'}> when 'true' -> + %% Line 201 + ( case State of + ( <( {'state',_78,_79,_rec0,_80,_81,_82,_83} + -| ['compiler_generated'] )> when 'true' -> + ( case State of + ( <( {'state',_85,_86,_87,_88,_89,_90,_rec1} + -| ['compiler_generated'] )> when 'true' -> + <_rec0,_rec1> + -| ['compiler_generated'] ) + ( <_91> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_84> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 202 + when 'true' -> + %% Line 203 + ( case State of + ( <( {'state',_92,_93,_rec2,_94,_95,_96,_97} + -| ['compiler_generated'] )> when 'true' -> + do apply 'close_device'/1 + (_rec2) + let <_9> = + apply %% Line 204 + 'open_log_file'/1 + (%% Line 204 + Log) + in <_9,%% Line 204 + Log> + -| ['compiler_generated'] ) + ( <_98> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + end + in %% Line 206 + ( case State of + ( <( {'state',_99,_100,_101,_rec3,_102,_103,_104} + -| ['compiler_generated'] )> when 'true' -> + let = + apply 'get_option'/3 + (Options, 'max', _rec3) + in %% Line 207 + ( case State of + ( <( {'state',_106,_107,_108,_109,_rec4,_110,_111} + -| ['compiler_generated'] )> when 'true' -> + let = + apply 'get_option'/3 + (Options, 'type', _rec4) + in let = + apply %% Line 208 + 'get_option'/3 + (%% Line 208 + Options, %% Line 208 + 'abort_on_error', %% Line 208 + 'false') + in %% Line 209 + ( case State of + ( <( {'state',_rec5,_113,_114,_115,_116,_117,_118} + -| ['compiler_generated'] )> when 'true' -> + let = + apply 'scan_files'/3 + (_rec5, Max, Type) + in %% Line 211 + case State of + <{'state',_rec7,_rec8,_rec9,_rec10,_rec11,_rec12,_rec13}> when 'true' -> + let <_25> = + {'state',_rec7,Data,( _224 + -| ['compiler_generated'] ),Max,Type,Abort,( _225 + -| ['compiler_generated'] )} + in %% Line 212 + {'reply','ok',_25} + ( <_120> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_119> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_112> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_105> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 213 + <_121,_X_From,{'state',_122,'undefined',_123,_124,_125,_126,_127}> when 'true' -> + %% Line 214 + {'reply',{'error','no_data'},{'state','undefined','undefined','undefined','undefined','undefined','undefined','undefined'}} + %% Line 215 + <{'list',Type},_X_From,State> when 'true' -> + %% Line 216 + ( case State of + ( <( {'state',_128,_rec14,_129,_130,_131,_132,_133} + -| ['compiler_generated'] )> when 'true' -> + do apply 'print_list'/3 + ('standard_io', _rec14, Type) + %% Line 217 + {'reply','ok',State} + -| ['compiler_generated'] ) + ( <_134> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 218 + <{'log_list',Type},_X_From,State> when 'true' -> + %% Line 219 + ( case State of + ( <( {'state',_135,_136,_rec15,_137,_138,_139,_140} + -| ['compiler_generated'] )> when 'true' -> + ( case State of + ( <( {'state',_142,_rec16,_143,_144,_145,_146,_147} + -| ['compiler_generated'] )> when 'true' -> + do apply 'print_list'/3 + (_rec15, _rec16, Type) + %% Line 220 + {'reply','ok',State} + -| ['compiler_generated'] ) + ( <_148> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_141> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 221 + <{'start_log',FileName},_X_From,State> when 'true' -> + let = + apply %% Line 222 + 'open_log_file'/1 + (%% Line 222 + FileName) + in %% Line 223 + case State of + <{'state',_149,_150,_151,_152,_153,_154,_155}> when 'true' -> + let <_36> = + call 'erlang':'setelement' + (4, State, NewDevice) + in {'reply','ok',_36} + ( <_156> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 224 + <'stop_log',_X_From,State> when 'true' -> + %% Line 225 + ( case State of + ( <( {'state',_157,_158,_rec18,_159,_160,_161,_162} + -| ['compiler_generated'] )> when 'true' -> + do apply 'close_device'/1 + (_rec18) + %% Line 226 + case State of + <{'state',_164,_165,_166,_167,_168,_169,_170}> when 'true' -> + let <_41> = + call 'erlang':'setelement' + (4, State, 'standard_io') + in {'reply','ok',_41} + ( <_171> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_163> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 227 + <{'show_number',Number},_X_From,State> when 'true' -> + %% Line 228 + case State of + <{'state',Dir,Data,Device,_172,_173,Abort,Log}> when 'true' -> + let = + apply %% Line 229 + 'print_report_by_num'/6 + (%% Line 229 + Dir, %% Line 229 + Data, %% Line 229 + Number, %% Line 229 + Device, %% Line 229 + Abort, %% Line 229 + Log) + in %% Line 230 + case State of + <{'state',_174,_175,_176,_177,_178,_179,_180}> when 'true' -> + let <_46> = + call 'erlang':'setelement' + (4, State, NewDevice) + in {'reply','ok',_46} + ( <_181> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + ( <_42> when 'true' -> + primop 'match_fail' + ({'badmatch',_42}) + -| ['compiler_generated'] ) + end + %% Line 231 + <{'show_type',Type},_X_From,State> when 'true' -> + %% Line 232 + case State of + <{'state',Dir,Data,Device,_182,_183,Abort,Log}> when 'true' -> + let = + apply %% Line 233 + 'print_typed_reports'/6 + (%% Line 233 + Dir, %% Line 233 + Data, %% Line 233 + Type, %% Line 233 + Device, %% Line 233 + Abort, %% Line 233 + Log) + in %% Line 234 + case State of + <{'state',_184,_185,_186,_187,_188,_189,_190}> when 'true' -> + let <_51> = + call 'erlang':'setelement' + (4, State, NewDevice) + in {'reply','ok',_51} + ( <_191> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + ( <_47> when 'true' -> + primop 'match_fail' + ({'badmatch',_47}) + -| ['compiler_generated'] ) + end + %% Line 235 + <'show',_X_From,State> when 'true' -> + %% Line 236 + case State of + <{'state',Dir,Data,Device,_192,_193,Abort,Log}> when 'true' -> + let = + apply %% Line 237 + 'print_all_reports'/5 + (%% Line 237 + Dir, %% Line 237 + Data, %% Line 237 + Device, %% Line 237 + Abort, %% Line 237 + Log) + in %% Line 238 + case State of + <{'state',_194,_195,_196,_197,_198,_199,_200}> when 'true' -> + let <_56> = + call 'erlang':'setelement' + (4, State, NewDevice) + in {'reply','ok',_56} + ( <_201> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + ( <_52> when 'true' -> + primop 'match_fail' + ({'badmatch',_52}) + -| ['compiler_generated'] ) + end + %% Line 239 + <{'grep',RegExp},_X_From,State> when 'true' -> + %% Line 240 + case State of + <{'state',Dir,Data,Device,_202,_203,Abort,Log}> when 'true' -> + %% Line 241 + try + apply 'print_grep_reports'/6 + (Dir, Data, RegExp, Device, Abort, Log) + of <_58> -> + %% Line 243 + case State of + <{'state',_204,_205,_206,_207,_208,_209,_210}> when 'true' -> + let <_61> = + call 'erlang':'setelement' + (4, State, _58) + in {'reply','ok',_61} + ( <_211> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + catch <_65,_64,_63> -> + %% Line 245 + case <_65,_64,_63> of + <( 'error' + -| ['compiler_generated'] ),Error,_212> when 'true' -> + %% Line 246 + {'reply',{'error',Error},State} + ( <_231,_232,_233> when 'true' -> + primop 'raise' + (_233, _232) + -| ['compiler_generated'] ) + end + ( <_57> when 'true' -> + primop 'match_fail' + ({'badmatch',_57}) + -| ['compiler_generated'] ) + end + %% Line 248 + <{'filter',Filters},_X_From,State> when 'true' -> + %% Line 249 + case State of + <{'state',Dir,Data,Device,_213,_214,Abort,Log}> when 'true' -> + %% Line 250 + try + apply 'filter_all_reports'/6 + (Dir, Data, Filters, Device, Abort, Log) + of <_67> -> + %% Line 252 + case State of + <{'state',_215,_216,_217,_218,_219,_220,_221}> when 'true' -> + let <_70> = + call 'erlang':'setelement' + (4, State, _67) + in {'reply','ok',_70} + ( <_222> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + catch <_74,_73,_72> -> + %% Line 254 + case <_74,_73,_72> of + <( 'error' + -| ['compiler_generated'] ),Error,_223> when 'true' -> + %% Line 255 + {'reply',{'error',Error},State} + ( <_235,_236,_237> when 'true' -> + primop 'raise' + (_237, _236) + -| ['compiler_generated'] ) + end + ( <_66> when 'true' -> + primop 'match_fail' + ({'badmatch',_66}) + -| ['compiler_generated'] ) + end + ( <_77,_76,_75> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_77,_76,_75}) + -| [{'function_name',{'handle_call',3}}] ) + -| ['compiler_generated'] ) + end +'terminate'/2 = + %% Line 258 + fun (_0,_1) -> + case <_0,_1> of + <_X_Reason,{'state',_4,_5,Device,_6,_7,_8,_9}> when 'true' -> + %% Line 259 + apply 'close_device'/1 + (Device) + ( <_3,_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3,_2}) + -| [{'function_name',{'terminate',2}}] ) + -| ['compiler_generated'] ) + end +'handle_cast'/2 = + %% Line 261 + fun (_0,_1) -> + %% Line 262 + {'noreply',_1} +'handle_info'/2 = + %% Line 263 + fun (_0,_1) -> + %% Line 264 + {'noreply',_1} +'code_change'/3 = + %% Line 265 + fun (_0,_1,_2) -> + %% Line 266 + {'ok',_1} +'open_log_file'/1 = + %% Line 273 + fun (_0) -> + case _0 of + <'standard_io'> when 'true' -> + 'standard_io' + %% Line 274 + + when let <_1> = + call 'erlang':'is_atom' + (_0) + in let <_2> = + call 'erlang':'=/=' + (_0, 'standard_error') + in call 'erlang':'and' + (_1, _2) -> + %% Line 275 + case call 'erlang':'whereis' + (Fd) of + %% Line 276 + <'undefined'> when 'true' -> + do call 'io':'format' + ([114|[98|[58|[32|[82|[101|[103|[105|[115|[116|[101|[114|[101|[100|[32|[110|[97|[109|[101|[32|[110|[111|[116|[32|[102|[111|[117|[110|[100|[32|[39|[126|[116|[115|[39|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 277 + [Fd|[]]) + do %% Line 278 + call 'io':'format' + ([114|[98|[58|[32|[85|[115|[105|[110|[103|[32|[115|[116|[97|[110|[100|[97|[114|[100|[95|[105|[111|[126|[110]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 279 + apply 'open_log_file'/1 + ('standard_io') + %% Line 280 + when 'true' -> + apply 'open_log_file'/1 + (Pid) + end + %% Line 282 + + when call 'erlang':'is_pid' + (_0) -> + Fd + %% Line 283 + + when call 'erlang':'is_list' + (_0) -> + %% Line 284 + case call 'file':'open' + (FileName, ['write'|['append'|[{'encoding','utf8'}]]]) of + %% Line 285 + <{'ok',Fd}> when 'true' -> + Fd + %% Line 286 + when 'true' -> + do %% Line 287 + call 'io':'format' + ([114|[98|[58|[32|[67|[97|[110|[110|[111|[116|[32|[111|[112|[101|[110|[32|[102|[105|[108|[101|[32|[39|[126|[116|[115|[39|[32|[40|[126|[119|[41|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 288 + [FileName|[Error|[]]]) + do %% Line 289 + call 'io':'format' + ([114|[98|[58|[32|[85|[115|[105|[110|[103|[32|[115|[116|[97|[110|[100|[97|[114|[100|[95|[105|[111|[126|[110]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 290 + 'standard_io' + end + %% Line 292 + <'standard_error'> when 'true' -> + do %% Line 293 + call 'io':'format' + ([114|[98|[58|[32|[85|[115|[105|[110|[103|[32|[115|[116|[97|[110|[100|[97|[114|[100|[95|[105|[111|[126|[110]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 294 + 'standard_io' + ( <_5> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5}) + -| [{'function_name',{'open_log_file',1}}] ) + -| ['compiler_generated'] ) + end +'close_device'/1 = + %% Line 296 + fun (_0) -> + case _0 of + + when call 'erlang':'is_pid' + (_0) -> + catch + %% Line 297 + call 'file':'close' + (Fd) + %% Line 298 + <_2> when 'true' -> + 'ok' + end +'get_option'/3 = + %% Line 300 + fun (_0,_1,_2) -> + %% Line 301 + case call 'lists':'keysearch' + (_1, 1, _0) of + %% Line 302 + <{'value',{_X_Key,Value}}> when 'true' -> + Value + %% Line 303 + <_7> when 'true' -> + _2 + end +'get_report_dir'/1 = + %% Line 306 + fun (_0) -> + %% Line 307 + case call 'lists':'keysearch' + ('report_dir', 1, _0) of + %% Line 308 + <{'value',{_X_Key,RptDir}}> when 'true' -> + RptDir + %% Line 309 + <_5> when 'true' -> + let <_1> = + catch + %% Line 310 + call 'application':'get_env' + ('sasl', 'error_logger_mf_dir') + in %% Line 310 + case _1 of + %% Line 311 + <{'ok',Dir}> when 'true' -> + Dir + %% Line 312 + <_6> when 'true' -> + %% Line 313 + call 'erlang':'exit' + ([99|[97|[110|[110|[111|[116|[32|[108|[111|[99|[97|[116|[101|[32|[114|[101|[112|[111|[114|[116|[32|[100|[105|[114|[101|[99|[116|[111|[114|[121]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + end + end +'scan_files'/3 = + %% Line 328 + fun (_0,_1,_2) -> + let <_3> = + call %% Line 329 + 'erlang':%% Line 329 + '++' + (_0, %% Line 329 + [47|[105|[110|[100|[101|[120]]]]]]) + in %% Line 329 + case call 'file':'open' + (_3, ['raw'|['read']]) of + %% Line 330 + <{'ok',Fd}> when 'true' -> + let <_4> = + catch + %% Line 331 + call 'file':'read' + (Fd, 1) + in %% Line 331 + case _4 of + %% Line 332 + <{'ok',[LastWritten|[]]}> when 'true' -> + %% Line 333 + case call 'file':'close' + (Fd) of + <'ok'> when 'true' -> + let = + apply %% Line 334 + 'make_file_list'/2 + (_0, %% Line 334 + LastWritten) + in %% Line 335 + apply 'scan_files'/4 + (_0, Files, _1, _2) + ( <_5> when 'true' -> + primop 'match_fail' + ({'badmatch',_5}) + -| ['compiler_generated'] ) + end + %% Line 336 + <_X_X> when 'true' -> + do %% Line 337 + ( call ( 'file' + -| ['result_not_wanted'] ):( 'close' + -| ['result_not_wanted'] ) + (Fd) + -| ['result_not_wanted'] ) + %% Line 338 + call 'erlang':'exit' + ([99|[97|[110|[110|[111|[116|[32|[114|[101|[97|[100|[32|[116|[104|[101|[32|[105|[110|[100|[101|[120|[32|[102|[105|[108|[101]]]]]]]]]]]]]]]]]]]]]]]]]]) + end + %% Line 340 + <_X_X> when 'true' -> + call 'erlang':'exit' + ([99|[97|[110|[110|[111|[116|[32|[114|[101|[97|[100|[32|[116|[104|[101|[32|[105|[110|[100|[101|[120|[32|[102|[105|[108|[101]]]]]]]]]]]]]]]]]]]]]]]]]]) + end +'make_file_list'/2 = + %% Line 343 + fun (_0,_1) -> + %% Line 344 + case call 'file':'list_dir' + (_0) of + %% Line 345 + <{'ok',FileNames}> when 'true' -> + let <_6> = + fun (_4) -> + let <_2> = + catch + %% Line 347 + call 'erlang':'list_to_integer' + (_4) + in %% Line 347 + case _2 of + %% Line 348 + + when call 'erlang':'is_integer' + (_2) -> + %% Line 349 + {'true',Int} + %% Line 350 + <_12> when 'true' -> + %% Line 351 + 'false' + end + in let = + call %% Line 346 + 'lists':%% Line 346 + 'zf' + (_6, %% Line 354 + FileNames) + in let <_8> = + call %% Line 355 + 'lists':%% Line 355 + 'sort' + (%% Line 355 + FileNumbers) + in %% Line 355 + apply 'shift'/2 + (_8, _1) + %% Line 356 + <_13> when 'true' -> + call 'erlang':'exit' + ({'bad_directory',_0}) + end +'shift'/2 = + %% Line 359 + fun (_0,_1) -> + %% Line 360 + apply 'shift'/3 + (_0, _1, []) +'shift'/3 = + %% Line 362 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <[H|T],_7,Res> + when call 'erlang':'=:=' + (_7, + H) -> + let <_3> = + call %% Line 363 + 'lists':%% Line 363 + 'reverse' + (%% Line 363 + T) + in %% Line 363 + [H|call 'erlang':'++' + (Res, _3)] + %% Line 364 + <[H|T],First,Res> when 'true' -> + %% Line 365 + apply 'shift'/3 + (T, First, [H|Res]) + %% Line 366 + <[],_8,Res> when 'true' -> + %% Line 367 + Res + ( <_6,_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5,_4}) + -| [{'function_name',{'shift',3}}] ) + -| ['compiler_generated'] ) + end +'scan_files'/4 = + %% Line 375 + fun (_0,_1,_2,_3) -> + %% Line 376 + apply 'scan_files'/6 + (_0, 1, _1, [], _2, _3) +'scan_files'/6 = + %% Line 377 + fun (_0,_1,_2,_3,_4,_5) -> + case <_0,_1,_2,_3,_4,_5> of + <_X_Dir,_17,[],Res,_X_Max,_X_Type> when 'true' -> + Res + %% Line 378 + <_X_Dir,_18,_X_Files,Res,Max,_X_Type> + when call 'erlang':'=<' + (Max, + 0) -> + Res + %% Line 379 + when 'true' -> + let = + apply %% Line 380 + 'get_report_data_from_file'/5 + (%% Line 380 + Dir, %% Line 380 + No, %% Line 380 + H, %% Line 380 + Max, %% Line 380 + Type) + in let = + call %% Line 381 + 'erlang':%% Line 381 + 'length' + (%% Line 381 + Data) + in let = + apply %% Line 382 + 'dec_max'/2 + (%% Line 382 + Max, %% Line 382 + Len) + in let = + call %% Line 383 + 'erlang':%% Line 383 + '+' + (%% Line 383 + No, %% Line 383 + Len) + in let = + call %% Line 384 + 'erlang':%% Line 384 + '++' + (%% Line 384 + Data, %% Line 384 + Res) + in %% Line 385 + apply 'scan_files'/6 + (Dir, NewNo, T, NewData, NewMax, Type) + ( <_16,_15,_14,_13,_12,_11> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_16,_15,_14,_13,_12,_11}) + -| [{'function_name',{'scan_files',6}}] ) + -| ['compiler_generated'] ) + end +'dec_max'/2 = + %% Line 387 + fun (_0,_1) -> + case <_0,_1> of + <'all',_4> when 'true' -> + 'all' + %% Line 388 + when 'true' -> + call 'erlang':'-' + (X, Y) + end +'get_report_data_from_file'/5 = + %% Line 390 + fun (_0,_1,_2,_3,_4) -> + let = + call %% Line 391 + 'erlang':%% Line 391 + 'integer_to_list' + (_2) + in let = + call %% Line 392 + 'lists':%% Line 392 + 'concat' + (%% Line 392 + [_0|[Fname|[]]]) + in %% Line 393 + case call 'file':'open' + (FileName, ['read']) of + %% Line 394 + <{'ok',Fd}> + when call 'erlang':'is_pid' + (Fd) -> + apply 'read_reports'/5 + (_1, Fd, Fname, _3, _4) + %% Line 395 + <_14> when 'true' -> + let <_7> = + call 'erlang':'++' + ([67|[97|[110|[39|[116|[32|[111|[112|[101|[110|[32|[102|[105|[108|[101|[32]]]]]]]]]]]]]]]], Fname) + in [{_1,'unknown',_7,[63|[63|[63]]],Fname,0}|[]] + end +'read_reports'/5 = + %% Line 406 + fun (_0,_1,_2,_3,_4) -> + do %% Line 407 + call 'io':'format' + ([114|[98|[58|[32|[114|[101|[97|[100|[105|[110|[103|[32|[114|[101|[112|[111|[114|[116|[46|[46|[46]]]]]]]]]]]]]]]]]]]]]) + let <_5> = + catch + %% Line 408 + apply 'read_reports'/3 + (_1, [], _4) + in %% Line 408 + case _5 of + %% Line 409 + <{'ok',Res}> when 'true' -> + %% Line 410 + case call 'file':'close' + (_1) of + <'ok'> when 'true' -> + do %% Line 411 + call 'io':'format' + ([100|[111|[110|[101|[46|[126|[110]]]]]]]) + let <_8> = + case <> of + %% Line 414 + <> + when try + let <_7> = + call 'erlang':'length' + (Res) + in call 'erlang':'>' + (_7, _3) + of -> + Try + catch -> + 'false' -> + %% Line 415 + call 'lists':'sublist' + (Res, 1, _3) + %% Line 416 + <> when 'true' -> + %% Line 417 + Res + end + in %% Line 419 + apply 'add_report_data'/3 + (_8, _0, _2) + ( <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + -| ['compiler_generated'] ) + end + %% Line 420 + <{'error',_@r0 = [Problem|Res]}> when 'true' -> + do %% Line 421 + ( call ( 'file' + -| ['result_not_wanted'] ):( 'close' + -| ['result_not_wanted'] ) + (_1) + -| ['result_not_wanted'] ) + do %% Line 422 + call 'io':'format' + ([69|[114|[114|[111|[114|[58|[32|[126|[116|[112|[126|[110]]]]]]]]]]]], [Problem|[]]) + let <_11> = + call %% Line 424 + 'erlang':%% Line 424 + 'length' + (%% Line 424 + Res) + in do %% Line 423 + call 'io':'format' + ([83|[97|[108|[118|[97|[103|[101|[100|[32|[126|[112|[32|[101|[110|[116|[114|[105|[101|[115|[32|[102|[114|[111|[109|[32|[99|[111|[114|[114|[117|[112|[116|[32|[114|[101|[112|[111|[114|[116|[32|[102|[105|[108|[101|[32|[126|[116|[115|[46|[46|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 424 + [_11|[_2|[]]]) + let <_13> = + case <> of + %% Line 427 + <> + when try + let <_12> = + call 'erlang':'+' + (1, call 'erlang':'length' + (Res)) + in call 'erlang':'>' + (_12, _3) + of -> + Try + catch -> + 'false' -> + %% Line 428 + call 'lists':'sublist' + (_@r0, 1, _3) + %% Line 429 + <> when 'true' -> + %% Line 430 + _@r0 + end + in %% Line 432 + apply 'add_report_data'/3 + (_13, _0, _2) + %% Line 433 + when 'true' -> + do %% Line 434 + call 'io':'format' + ([101|[114|[114|[32|[126|[116|[112|[126|[110]]]]]]]]], [Else|[]]) + let <_15> = + call %% Line 435 + 'erlang':%% Line 435 + '++' + (%% Line 435 + [67|[97|[110|[39|[116|[32|[114|[101|[97|[100|[32|[114|[101|[112|[111|[114|[116|[115|[32|[102|[114|[111|[109|[32|[102|[105|[108|[101|[32]]]]]]]]]]]]]]]]]]]]]]]]]]]]], _2) + in %% Line 435 + [{_0,'unknown',_15,%% Line 436 + [63|[63|[63]]],_2,%% Line 436 + 0}|%% Line 436 + []] + end +'add_report_data'/3 = + %% Line 446 + fun (_0,_1,_2) -> + %% Line 447 + apply 'add_report_data'/4 + (_0, _1, _2, []) +'add_report_data'/4 = + %% Line 448 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <[{Type,ShortDescr,Date,FilePos}|T],No,FName,Res> when 'true' -> + let <_4> = + call %% Line 449 + 'erlang':%% Line 449 + '+' + (%% Line 449 + No, %% Line 449 + 1) + in %% Line 449 + apply 'add_report_data'/4 + (T, _4, FName, %% Line 450 + [{No,Type,ShortDescr,Date,FName,FilePos}|Res]) + %% Line 451 + <[],_X_No,_X_FName,Res> when 'true' -> + Res + ( <_8,_7,_6,_5> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_8,_7,_6,_5}) + -| [{'function_name',{'add_report_data',4}}] ) + -| ['compiler_generated'] ) + end +'read_reports'/3 = + %% Line 453 + fun (_0,_1,_2) -> + %% Line 454 + case call 'file':'position' + (_0, 'cur') of + <{'ok',FilePos}> when 'true' -> + let <_4> = + catch + %% Line 455 + apply 'read_report'/1 + (_0) + in %% Line 455 + case _4 of + %% Line 456 + <{'ok',Report}> when 'true' -> + let = + apply %% Line 457 + 'get_type'/1 + (%% Line 457 + Report) + in %% Line 458 + case apply 'get_short_descr'/1 + (Report) of + <{ShortDescr,Date}> when 'true' -> + let = + {%% Line 459 + RealType,%% Line 459 + ShortDescr,%% Line 459 + Date,%% Line 459 + FilePos} + in %% Line 460 + case <> of + %% Line 461 + <> + when call 'erlang':'=:=' + (_2, + 'all') -> + %% Line 462 + apply 'read_reports'/3 + (_0, [Rep|_1], _2) + %% Line 463 + <> + when call 'erlang':'==' + (RealType, + _2) -> + %% Line 464 + apply 'read_reports'/3 + (_0, [Rep|_1], _2) + %% Line 465 + <> + when call 'erlang':'is_list' + (_2) -> + %% Line 466 + case call 'lists':'member' + (RealType, _2) of + %% Line 467 + <'true'> when 'true' -> + %% Line 468 + apply 'read_reports'/3 + (_0, [Rep|_1], _2) + %% Line 469 + <_13> when 'true' -> + %% Line 470 + apply 'read_reports'/3 + (_0, _1, _2) + end + %% Line 472 + <> when 'true' -> + %% Line 473 + apply 'read_reports'/3 + (_0, _1, _2) + end + ( <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + -| ['compiler_generated'] ) + end + %% Line 475 + <{'error',Error}> when 'true' -> + %% Line 476 + {'error',[{'unknown',Error,[],FilePos}|_1]} + %% Line 477 + <'eof'> when 'true' -> + %% Line 478 + {'ok',_1} + %% Line 479 + <{'EXIT',Reason}> when 'true' -> + %% Line 480 + [{'unknown',Reason,[],FilePos}|_1] + ( <_9> when 'true' -> + primop 'match_fail' + ({'case_clause',_9}) + -| ['compiler_generated'] ) + end + ( <_3> when 'true' -> + primop 'match_fail' + ({'badmatch',_3}) + -| ['compiler_generated'] ) + end +'read_report'/1 = + %% Line 483 + fun (_0) -> + %% Line 484 + case call 'io':'get_chars' + (_0, '', 2) of + %% Line 485 + <[Hi|[Lo|[]]]> when 'true' -> + let = + apply %% Line 486 + 'get_int16'/2 + (%% Line 486 + Hi, %% Line 486 + Lo) + in %% Line 487 + case call 'io':'get_chars' + (_0, '', Size) of + %% Line 488 + <'eof'> when 'true' -> + %% Line 489 + {'error',[80|[114|[101|[109|[97|[116|[117|[114|[101|[32|[101|[110|[100|[32|[111|[102|[32|[102|[105|[108|[101]]]]]]]]]]]]]]]]]]]]]} + %% Line 490 + when 'true' -> + let = + call %% Line 491 + 'erlang':%% Line 491 + 'list_to_binary' + (%% Line 491 + List) + in let = + call %% Line 492 + 'erlang':%% Line 492 + 'make_ref' + () + in let <_5> = + catch + let <_4> = + call %% Line 493 + 'erlang':%% Line 493 + 'binary_to_term' + (%% Line 493 + Bin) + in %% Line 493 + {Ref,_4} + in %% Line 493 + case _5 of + %% Line 494 + <{'EXIT',_10}> when 'true' -> + %% Line 495 + {'error',[73|[110|[99|[111|[109|[112|[108|[101|[116|[101|[32|[101|[114|[108|[97|[110|[103|[32|[116|[101|[114|[109|[32|[105|[110|[32|[108|[111|[103]]]]]]]]]]]]]]]]]]]]]]]]]]]]]} + %% Line 496 + <{_11,Term}> + when call 'erlang':'=:=' + (_11, + Ref) -> + %% Line 497 + {'ok',Term} + ( <_6> when 'true' -> + primop 'match_fail' + ({'case_clause',_6}) + -| ['compiler_generated'] ) + end + end + %% Line 500 + <'eof'> when 'true' -> + %% Line 501 + 'eof' + ( <_8> when 'true' -> + primop 'match_fail' + ({'case_clause',_8}) + -| ['compiler_generated'] ) + end +'get_int16'/2 = + %% Line 504 + fun (_0,_1) -> + let <_3> = + call %% Line 505 + 'erlang':%% Line 505 + 'bsl' + (_0, %% Line 505 + 8) + in let <_4> = + call %% Line 505 + 'erlang':%% Line 505 + 'band' + (_3, %% Line 505 + 65280) + in let <_2> = + call %% Line 505 + 'erlang':%% Line 505 + 'band' + (_1, %% Line 505 + 255) + in %% Line 505 + call 'erlang':'bor' + (_4, _2) +'get_type'/1 = + %% Line 512 + fun (_0) -> + case _0 of + <{_X_Time,{'error_report',_X_Pid,{_2,'crash_report',_3}}}> when 'true' -> + %% Line 513 + 'crash_report' + %% Line 514 + <{_X_Time,{'error_report',_X_Pid,{_4,'supervisor_report',_5}}}> when 'true' -> + %% Line 515 + 'supervisor_report' + %% Line 516 + <{_X_Time,{'info_report',_X_Pid,{_6,'progress',_7}}}> when 'true' -> + %% Line 517 + 'progress' + %% Line 518 + <{_X_Time,{Type,_8,_9}}> when 'true' -> + Type + %% Line 519 + <_10> when 'true' -> + 'unknown' + end +'get_short_descr'/1 = + %% Line 521 + fun (_0) -> + case _0 of + <{{Date,Time},{'error_report',Pid,{_13,'crash_report',Rep}}}> when 'true' -> + %% Line 522 + case Rep of + <[OwnRep|_14]> when 'true' -> + let <_4> = + case %% Line 524 + call 'lists':'keysearch' + ('registered_name', 1, OwnRep) of + %% Line 525 + <{'value',{_X_Key,[]}}> when 'true' -> + %% Line 526 + case call 'lists':'keysearch' + ('initial_call', 1, OwnRep) of + %% Line 527 + <{'value',{_X_K,{M,_X_F,_X_A}}}> when 'true' -> + M + %% Line 528 + <_15> when 'true' -> + Pid + end + %% Line 530 + <{'value',{_X_Key,N}}> when 'true' -> + N + %% Line 531 + <_16> when 'true' -> + Pid + end + in let <_6> = + apply %% Line 533 + 'date_str'/2 + (%% Line 533 + Date, %% Line 533 + Time) + in %% Line 533 + {_4,_6} + ( <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + -| ['compiler_generated'] ) + end + %% Line 534 + <{{Date,Time},{'error_report',Pid,{_17,'supervisor_report',Rep}}}> when 'true' -> + let <_8> = + case %% Line 536 + call 'lists':'keysearch' + ('supervisor', 1, Rep) of + %% Line 537 + <{'value',{_X_Key,N}}> + when call 'erlang':'is_atom' + (N) -> + N + %% Line 538 + <_18> when 'true' -> + Pid + end + in let <_10> = + apply %% Line 540 + 'date_str'/2 + (%% Line 540 + Date, %% Line 540 + Time) + in %% Line 540 + {_8,_10} + %% Line 541 + <{{Date,Time},{_X_Type,Pid,_19}}> when 'true' -> + let <_11> = + apply %% Line 542 + 'date_str'/2 + (%% Line 542 + Date, %% Line 542 + Time) + in %% Line 542 + {Pid,_11} + %% Line 543 + <_20> when 'true' -> + %% Line 544 + {'???',[63|[63|[63]]]} + end +'date_str'/2 = + %% Line 546 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + %% Line 547 + case call 'application':'get_env' + ('sasl', 'utc_log') of + %% Line 548 + <{'ok','true'}> when 'true' -> + %% Line 549 + case %% Line 550 + apply 'local_time_to_universal_time'/1 + ({Date,Time}) of + <{{YY,MoMo,DD},{HH,MiMi,SS}}> when 'true' -> + let <_3> = + call %% Line 551 + 'io_lib':%% Line 551 + 'format' + (%% Line 551 + [126|[119|[45|[126|[50|[46|[50|[46|[48|[119|[45|[126|[50|[46|[50|[46|[48|[119|[32|[126|[50|[46|[50|[46|[48|[119|[58|[126|[50|[46|[50|[46|[48|[119|[58|[126|[50|[46|[50|[46|[48|[119|[32|[85|[84|[67]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 553 + [YY|[MoMo|[DD|[HH|[MiMi|[SS|[]]]]]]]) + in %% Line 551 + call 'lists':'flatten' + (_3) + ( <_2> when 'true' -> + primop 'match_fail' + ({'badmatch',_2}) + -| ['compiler_generated'] ) + end + %% Line 554 + <_8> when 'true' -> + let <_4> = + call %% Line 555 + 'io_lib':%% Line 555 + 'format' + (%% Line 555 + [126|[119|[45|[126|[50|[46|[50|[46|[48|[119|[45|[126|[50|[46|[50|[46|[48|[119|[32|[126|[50|[46|[50|[46|[48|[119|[58|[126|[50|[46|[50|[46|[48|[119|[58|[126|[50|[46|[50|[46|[48|[119]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 557 + [Y|[Mo|[D|[H|[Mi|[S|[]]]]]]]) + in %% Line 555 + call 'lists':'flatten' + (_4) + end + ( <_7,_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_7,_6}) + -| [{'function_name',{'date_str',2}}] ) + -| ['compiler_generated'] ) + end +'local_time_to_universal_time'/1 = + %% Line 560 + fun (_0) -> + case _0 of + <_@r0 = {Date,Time}> when 'true' -> + %% Line 561 + case call 'calendar':'local_time_to_universal_time_dst' + (_@r0) of + %% Line 562 + <[UCT|[]]> when 'true' -> + %% Line 563 + UCT + %% Line 564 + <[UCT1|[_X_UCT2|[]]]> when 'true' -> + %% Line 565 + UCT1 + %% Line 566 + <[]> when 'true' -> + %% Line 567 + _@r0 + ( <_1> when 'true' -> + primop 'match_fail' + ({'case_clause',_1}) + -| ['compiler_generated'] ) + end + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'local_time_to_universal_time',1}}] ) + -| ['compiler_generated'] ) + end +'print_list'/3 = + %% Line 571 + fun (_0,_1,_2) -> + let = + call %% Line 572 + 'misc_supp':%% Line 572 + 'modifier' + (_0) + in %% Line 574 + case apply 'find_widths'/5 + (_1, Modifier, 7, 13, []) of + <{DescrWidth,DateWidth,Data}> when 'true' -> + let = + call %% Line 575 + 'lists':%% Line 575 + 'concat' + (%% Line 575 + [[126|[52|[115|[126|[50|[48|[115|[32|[126]]]]]]]]]|[DescrWidth|[[115|[126|[50|[48|[115|[126|[110]]]]]]]]]]) + in do %% Line 576 + call 'io':'format' + (_0, Format, [[78|[111]]|[[84|[121|[112|[101]]]]|[[80|[114|[111|[99|[101|[115|[115]]]]]]]|[[68|[97|[116|[101|[32|[32|[32|[32|[32|[84|[105|[109|[101]]]]]]]]]]]]]]]]]) + do %% Line 577 + call 'io':'format' + (_0, Format, [[61|[61]]|[[61|[61|[61|[61]]]]|[[61|[61|[61|[61|[61|[61|[61]]]]]]]|[[61|[61|[61|[61|[32|[32|[32|[32|[32|[61|[61|[61|[61]]]]]]]]]]]]]]]]]) + %% Line 578 + apply 'print_list'/6 + (_0, Data, _2, DescrWidth, DateWidth, Modifier) + ( <_5> when 'true' -> + primop 'match_fail' + ({'badmatch',_5}) + -| ['compiler_generated'] ) + end +'print_list'/6 = + %% Line 579 + fun (_0,_1,_2,_3,_4,_5) -> + case <_0,_1,_2,_3,_4,_5> of + <_12,[],_13,_14,_15,_16> when 'true' -> + 'true' + %% Line 580 + when 'true' -> + do %% Line 581 + apply 'print_one_report'/6 + (Fd, H, Type, Width, DateWidth, Modifier) + %% Line 582 + apply 'print_list'/6 + (Fd, T, Type, Width, DateWidth, Modifier) + ( <_11,_10,_9,_8,_7,_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_11,_10,_9,_8,_7,_6}) + -| [{'function_name',{'print_list',6}}] ) + -| ['compiler_generated'] ) + end +'find_widths'/5 = + %% Line 585 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + <[],_X_Modifier,DescrWidth,DateWidth,Data> when 'true' -> + let <_7> = + call %% Line 586 + 'erlang':%% Line 586 + '+' + (%% Line 586 + DescrWidth, %% Line 586 + 1) + in let <_6> = + call %% Line 586 + 'erlang':%% Line 586 + '+' + (%% Line 586 + DateWidth, %% Line 586 + 1) + in let <_5> = + call %% Line 586 + 'lists':%% Line 586 + 'reverse' + (%% Line 586 + Data) + in %% Line 586 + {_7,_6,_5} + %% Line 587 + <[H|T],Modifier,DescrWidth,DateWidth,Data> when 'true' -> + let = + call %% Line 588 + 'erlang':%% Line 588 + 'element' + (%% Line 588 + 3, %% Line 588 + H) + in let <_9> = + call %% Line 589 + 'erlang':%% Line 589 + '++' + (%% Line 589 + Modifier, %% Line 589 + [119]) + in let <_10> = + [126|_9] + in let = + call %% Line 589 + 'io_lib':%% Line 589 + 'format' + (_10, %% Line 589 + [DescrTerm|[]]) + in let = + call %% Line 590 + 'string':%% Line 590 + 'length' + (%% Line 590 + Descr) + in let <_13> = + case <> of + %% Line 593 + <> + when call 'erlang':'>' + (DescrTry, + DescrWidth) -> + DescrTry + %% Line 594 + <> when 'true' -> + DescrWidth + end + in let <_15> = + call %% Line 596 + 'erlang':%% Line 596 + 'element' + (%% Line 596 + 4, %% Line 596 + H) + in let = + call %% Line 596 + 'string':%% Line 596 + 'length' + (_15) + in let <_17> = + case <> of + %% Line 599 + <> + when call 'erlang':'>' + (DateTry, + DateWidth) -> + DateTry + %% Line 600 + <> when 'true' -> + DateWidth + end + in let = + call %% Line 602 + 'erlang':%% Line 602 + 'setelement' + (%% Line 602 + 3, %% Line 602 + H, %% Line 602 + Descr) + in %% Line 603 + apply 'find_widths'/5 + (T, Modifier, _13, _17, [NewH|Data]) + ( <_24,_23,_22,_21,_20> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_24,_23,_22,_21,_20}) + -| [{'function_name',{'find_widths',5}}] ) + -| ['compiler_generated'] ) + end +'print_one_report'/6 = + %% Line 605 + fun (_0,_1,_2,_3,_4,_5) -> + case <_0,_1,_2,_3,_4,_5> of + when 'true' -> + %% Line 608 + case <> of + %% Line 609 + <> + when call 'erlang':'=:=' + (WantedType, + 'all') -> + %% Line 610 + apply 'print_short_descr'/8 + (Fd, No, RealType, ShortDescr, Date, Width, %% Line 611 + DateWidth, %% Line 611 + Modifier) + %% Line 612 + <> + when call 'erlang':'==' + (WantedType, + RealType) -> + %% Line 613 + apply 'print_short_descr'/8 + (Fd, No, RealType, ShortDescr, Date, Width, %% Line 614 + DateWidth, %% Line 614 + Modifier) + %% Line 615 + <> when 'true' -> + 'ok' + end + ( <_11,_10,_9,_8,_7,_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_11,_10,_9,_8,_7,_6}) + -| [{'function_name',{'print_one_report',6}}] ) + -| ['compiler_generated'] ) + end +'print_short_descr'/8 = + %% Line 618 + fun (_0,_1,_2,_3,_4,_5,_6,_7) -> + let = + call %% Line 619 + 'lists':%% Line 619 + 'concat' + (%% Line 619 + [[126|[52|[119|[126|[50|[48]]]]]]|[_7|[[119|[32|[126]]]|[_5|[_7|[[115|[126]]|%% Line 620 + [_6|[[115|[126|[110]]]]]]]]]]]) + in %% Line 621 + call 'io':'format' + (_0, Format, [_1|[_2|[_3|[_4|[]]]]]) +'print_report_by_num'/6 = + %% Line 623 + fun (_0,_1,_2,_3,_4,_5) -> + %% Line 624 + case apply 'print_report'/6 + (_0, _1, _2, _3, _4, _5) of + <{_13,Device1}> when 'true' -> + %% Line 625 + Device1 + ( <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + -| ['compiler_generated'] ) + end +'print_typed_reports'/6 = + %% Line 627 + fun (_0,_1,_2,_3,_4,_5) -> + case <_0,_1,_2,_3,_4,_5> of + <_X_Dir,[],_X_Type,Device,_X_Abort,_X_Log> when 'true' -> + %% Line 628 + Device + %% Line 629 + when 'true' -> + let <_6> = + call %% Line 631 + 'erlang':%% Line 631 + 'hd' + (%% Line 631 + Data) + in let <_10> = + case %% Line 631 + call 'erlang':'element' + (2, _6) of + %% Line 632 + <_19> + when call 'erlang':'=:=' + (_19, + Type) -> + let <_7> = + call %% Line 633 + 'erlang':%% Line 633 + 'hd' + (%% Line 633 + Data) + in let <_8> = + call %% Line 633 + 'erlang':%% Line 633 + 'element' + (%% Line 633 + 1, _7) + in %% Line 633 + apply 'print_report'/6 + (Dir, Data, _8, Device, Abort, Log) + %% Line 634 + <_20> when 'true' -> + %% Line 635 + {'proceed',Device} + end + in %% Line 630 + case _10 of + <{Next,Device1}> when 'true' -> + %% Line 637 + case <> of + <> + when call 'erlang':'=:=' + (Next, + 'abort') -> + %% Line 638 + Device1 + %% Line 639 + <> when 'true' -> + let <_12> = + call %% Line 640 + 'erlang':%% Line 640 + 'tl' + (%% Line 640 + Data) + in %% Line 640 + apply 'print_typed_reports'/6 + (Dir, _12, Type, Device1, Abort, Log) + end + ( <_11> when 'true' -> + primop 'match_fail' + ({'badmatch',_11}) + -| ['compiler_generated'] ) + end + end +'print_all_reports'/5 = + %% Line 643 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + <_X_Dir,[],Device,_X_Abort,_X_Log> when 'true' -> + %% Line 644 + Device + %% Line 645 + when 'true' -> + let <_5> = + call %% Line 646 + 'erlang':%% Line 646 + 'hd' + (%% Line 646 + Data) + in let <_6> = + call %% Line 646 + 'erlang':%% Line 646 + 'element' + (%% Line 646 + 1, _5) + in %% Line 646 + case apply 'print_report'/6 + (Dir, Data, _6, %% Line 647 + Device, %% Line 647 + Abort, %% Line 647 + Log) of + <{Next,Device1}> when 'true' -> + %% Line 648 + case <> of + <> + when call 'erlang':'=:=' + (Next, + 'abort') -> + %% Line 649 + Device1 + %% Line 650 + <> when 'true' -> + let <_8> = + call %% Line 651 + 'erlang':%% Line 651 + 'tl' + (%% Line 651 + Data) + in %% Line 651 + apply 'print_all_reports'/5 + (Dir, _8, Device1, Abort, Log) + end + ( <_7> when 'true' -> + primop 'match_fail' + ({'badmatch',_7}) + -| ['compiler_generated'] ) + end + end +'print_report'/6 = + %% Line 654 + fun (_0,_1,_2,_3,_4,_5) -> + %% Line 655 + case apply 'find_report'/2 + (_1, _2) of + %% Line 656 + <{Fname,FilePosition}> when 'true' -> + let = + call %% Line 657 + 'lists':%% Line 657 + 'concat' + (%% Line 657 + [_0|[Fname|[]]]) + in %% Line 658 + case call 'file':'open' + (FileName, ['read']) of + %% Line 659 + <{'ok',Fd}> when 'true' -> + %% Line 660 + apply 'read_rep'/5 + (Fd, FilePosition, _3, _4, _5) + %% Line 661 + <_15> when 'true' -> + do %% Line 662 + call 'io':'format' + ([114|[98|[58|[32|[99|[97|[110|[39|[116|[32|[111|[112|[101|[110|[32|[102|[105|[108|[101|[32|[126|[116|[112|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]], [Fname|[]]) + %% Line 663 + {'proceed',_3} + end + %% Line 665 + <'no_report'> when 'true' -> + %% Line 666 + {'proceed',_3} + ( <_8> when 'true' -> + primop 'match_fail' + ({'case_clause',_8}) + -| ['compiler_generated'] ) + end +'find_report'/2 = + %% Line 669 + fun (_0,_1) -> + case <_0,_1> of + <[{No,_X_Type,_X_Descr,_X_Date,Fname,FilePosition}|_X_T],_4> + when call 'erlang':'=:=' + (_4, + No) -> + %% Line 670 + {Fname,FilePosition} + %% Line 671 + <[_X_H|T],No> when 'true' -> + %% Line 672 + apply 'find_report'/2 + (T, No) + %% Line 673 + <[],No> when 'true' -> + do %% Line 674 + call 'io':'format' + ([84|[104|[101|[114|[101|[32|[105|[115|[32|[110|[111|[32|[114|[101|[112|[111|[114|[116|[32|[119|[105|[116|[104|[32|[110|[117|[109|[98|[101|[114|[32|[126|[112|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], [No|[]]) + %% Line 675 + 'no_report' + ( <_3,_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3,_2}) + -| [{'function_name',{'find_report',2}}] ) + -| ['compiler_generated'] ) + end +'print_grep_reports'/6 = + %% Line 677 + fun (_0,_1,_2,_3,_4,_5) -> + case <_0,_1,_2,_3,_4,_5> of + <_X_Dir,[],_X_RegExp,Device,_X_Abort,_X_Log> when 'true' -> + %% Line 678 + Device + %% Line 679 + when 'true' -> + let <_6> = + call %% Line 680 + 'erlang':%% Line 680 + 'hd' + (%% Line 680 + Data) + in let <_7> = + call %% Line 680 + 'erlang':%% Line 680 + 'element' + (%% Line 680 + 1, _6) + in %% Line 680 + case apply 'print_grep_report'/7 + (Dir, Data, _7, %% Line 681 + Device, %% Line 681 + RegExp, %% Line 681 + Abort, %% Line 681 + Log) of + <{Next,Device1}> when 'true' -> + %% Line 682 + case <> of + <> + when call 'erlang':'=:=' + (Next, + 'abort') -> + %% Line 683 + Device1 + %% Line 684 + <> when 'true' -> + let <_9> = + call %% Line 685 + 'erlang':%% Line 685 + 'tl' + (%% Line 685 + Data) + in %% Line 685 + apply 'print_grep_reports'/6 + (Dir, _9, RegExp, Device1, Abort, Log) + end + ( <_8> when 'true' -> + primop 'match_fail' + ({'badmatch',_8}) + -| ['compiler_generated'] ) + end + end +'print_grep_report'/7 = + %% Line 688 + fun (_0,_1,_2,_3,_4,_5,_6) -> + %% Line 689 + case apply 'find_report'/2 + (_1, _2) of + <{Fname,FilePosition}> when 'true' -> + let = + call %% Line 690 + 'lists':%% Line 690 + 'concat' + (%% Line 690 + [_0|[Fname|[]]]) + in %% Line 691 + case call 'file':'open' + (FileName, ['read']) of + %% Line 692 + <{'ok',Fd}> + when call 'erlang':'is_pid' + (Fd) -> + %% Line 693 + apply 'check_rep'/7 + (Fd, FilePosition, _3, _4, _2, _5, _6) + %% Line 694 + <_17> when 'true' -> + do %% Line 695 + call 'io':'format' + ([114|[98|[58|[32|[99|[97|[110|[39|[116|[32|[111|[112|[101|[110|[32|[102|[105|[108|[101|[32|[126|[116|[112|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]], [Fname|[]]) + %% Line 696 + {'proceed',_3} + end + ( <_7> when 'true' -> + primop 'match_fail' + ({'badmatch',_7}) + -| ['compiler_generated'] ) + end +'check_rep'/7 = + %% Line 699 + fun (_0,_1,_2,_3,_4,_5,_6) -> + %% Line 700 + case apply 'read_rep_msg'/2 + (_0, _1) of + %% Line 701 + <{Date,Msg}> when 'true' -> + let <_7> = + call %% Line 702 + 'io_lib':%% Line 702 + 'format' + (%% Line 702 + [126|[116|[112]]], %% Line 702 + [Msg|[]]) + in let = + call %% Line 702 + 'lists':%% Line 702 + 'flatten' + (_7) + in %% Line 703 + case apply 'run_re'/2 + (MsgStr, _3) of + %% Line 704 + <'match'> when 'true' -> + do %% Line 705 + call 'io':'format' + ([70|[111|[117|[110|[100|[32|[109|[97|[116|[99|[104|[32|[105|[110|[32|[114|[101|[112|[111|[114|[116|[32|[110|[117|[109|[98|[101|[114|[32|[126|[119|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], [_4|[]]) + let <_9> = + catch + %% Line 706 + call 'rb_format_supp':'print' + (Date, Msg, _2) + in %% Line 706 + case _9 of + %% Line 707 + <{'EXIT',_20}> when 'true' -> + %% Line 708 + apply 'handle_bad_form'/5 + (Date, Msg, _2, _5, _6) + %% Line 709 + <_21> when 'true' -> + %% Line 710 + {'proceed',_2} + end + %% Line 712 + <_22> when 'true' -> + %% Line 713 + {'proceed',_2} + end + %% Line 715 + <_23> when 'true' -> + do %% Line 716 + call 'io':'format' + ([114|[98|[58|[32|[67|[97|[110|[110|[111|[116|[32|[114|[101|[97|[100|[32|[102|[114|[111|[109|[32|[102|[105|[108|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 717 + {'proceed',_2} + end +'run_re'/2 = + %% Line 720 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + %% Line 721 + apply 'run_re'/3 + (Subject, Regexp, Options) + %% Line 722 + when 'true' -> + %% Line 723 + apply 'run_re'/3 + (Subject, Regexp, []) + end +'run_re'/3 = + %% Line 725 + fun (_0,_1,_2) -> + let <_3> = + call %% Line 726 + 'erlang':%% Line 726 + '--' + (_2, %% Line 726 + ['unicode']) + in %% Line 726 + case call 're':'run' + (_0, _1, ['unicode'|_3]) of + %% Line 727 + <'nomatch'> when 'true' -> + %% Line 728 + 'nomatch' + %% Line 729 + <_8> when 'true' -> + %% Line 730 + 'match' + end +'filter_all_reports'/6 = + %% Line 733 + fun (_0,_1,_2,_3,_4,_5) -> + case <_0,_1,_2,_3,_4,_5> of + <_X_Dir,[],_X_Filters,Device,_X_Abort,_X_Log> when 'true' -> + %% Line 734 + Device + %% Line 735 + when 'true' -> + let <_6> = + call %% Line 736 + 'erlang':%% Line 736 + 'hd' + (%% Line 736 + Data) + in let <_7> = + call %% Line 736 + 'erlang':%% Line 736 + 'element' + (%% Line 736 + 1, _6) + in %% Line 736 + case apply 'filter_report'/7 + (Dir, Data, Filters, _7, %% Line 737 + Device, %% Line 737 + Abort, %% Line 737 + Log) of + <{Next,Device1}> when 'true' -> + %% Line 738 + case <> of + <> + when call 'erlang':'=:=' + (Next, + 'abort') -> + %% Line 739 + Device1 + %% Line 740 + <> when 'true' -> + let <_9> = + call %% Line 741 + 'erlang':%% Line 741 + 'tl' + (%% Line 741 + Data) + in %% Line 741 + apply 'filter_all_reports'/6 + (Dir, _9, Filters, Device1, Abort, Log) + end + ( <_8> when 'true' -> + primop 'match_fail' + ({'badmatch',_8}) + -| ['compiler_generated'] ) + end + end +'filter_report'/7 = + %% Line 744 + fun (_0,_1,_2,_3,_4,_5,_6) -> + %% Line 745 + case apply 'find_report'/2 + (_1, _3) of + %% Line 746 + <{Fname,FilePosition}> when 'true' -> + let = + call %% Line 747 + 'lists':%% Line 747 + 'concat' + (%% Line 747 + [_0|[Fname|[]]]) + in %% Line 748 + case call 'file':'open' + (FileName, ['read']) of + %% Line 749 + <{'ok',Fd}> when 'true' -> + %% Line 750 + apply 'filter_rep'/6 + (_2, Fd, FilePosition, _4, _5, _6) + %% Line 751 + <_17> when 'true' -> + do %% Line 752 + call 'io':'format' + ([114|[98|[58|[32|[99|[97|[110|[39|[116|[32|[111|[112|[101|[110|[32|[102|[105|[108|[101|[32|[126|[116|[112|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]], [Fname|[]]) + %% Line 753 + {'proceed',_4} + end + %% Line 755 + <'no_report'> when 'true' -> + %% Line 756 + {'proceed',_4} + ( <_9> when 'true' -> + primop 'match_fail' + ({'case_clause',_9}) + -| ['compiler_generated'] ) + end +'filter_rep'/6 = + %% Line 759 + fun (_0,_1,_2,_3,_4,_5) -> + case <_0,_1,_2,_3,_4,_5> of + <{Filters,FDates},Fd,FilePosition,Device,Abort,Log> when 'true' -> + let = + apply %% Line 760 + 'read_rep_msg'/2 + (%% Line 760 + Fd, %% Line 760 + FilePosition) + in %% Line 761 + case RepMsg of + %% Line 762 + <{_X_DateStr,{Date,_X_Msg}}> when 'true' -> + %% Line 763 + case apply 'compare_dates'/2 + (Date, FDates) of + %% Line 764 + <'true'> when 'true' -> + %% Line 765 + apply 'print_filter_report'/5 + (RepMsg, Filters, Device, Abort, Log) + %% Line 766 + <_17> when 'true' -> + %% Line 767 + {'proceed',Device} + end + %% Line 769 + <_18> when 'true' -> + do %% Line 770 + call 'io':'format' + ([114|[98|[58|[32|[67|[97|[110|[110|[111|[116|[32|[114|[101|[97|[100|[32|[102|[114|[111|[109|[32|[102|[105|[108|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 771 + {'proceed',Device} + end + %% Line 773 + when 'true' -> + %% Line 775 + case apply 'read_rep_msg'/2 + (Fd, FilePosition) of + %% Line 776 + <_@r0 = {Date,Msg}> when 'true' -> + %% Line 777 + apply 'print_filter_report'/5 + (_@r0, Filters, Device, Abort, Log) + %% Line 778 + <_19> when 'true' -> + do %% Line 779 + call 'io':'format' + ([114|[98|[58|[32|[67|[97|[110|[110|[111|[116|[32|[114|[101|[97|[100|[32|[102|[114|[111|[109|[32|[102|[105|[108|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 780 + {'proceed',Device} + end + end +'filter_report'/2 = + %% Line 783 + fun (_0,_1) -> + case <_0,_1> of + <[],_X_Msg> when 'true' -> + %% Line 784 + 'true' + %% Line 785 + <[{Key,Value}|T],Msg> when 'true' -> + %% Line 786 + case call 'proplists':'get_value' + (Key, Msg) of + %% Line 787 + <_14> + when call 'erlang':'=:=' + (_14, + Value) -> + %% Line 788 + apply 'filter_report'/2 + (T, Msg) + %% Line 789 + <_15> when 'true' -> + %% Line 790 + 'false' + end + %% Line 792 + <[{Key,Value,'no'}|T],Msg> when 'true' -> + %% Line 793 + case call 'proplists':'get_value' + (Key, Msg) of + %% Line 794 + <_16> + when call 'erlang':'=:=' + (_16, + Value) -> + %% Line 795 + 'false' + %% Line 796 + <_17> when 'true' -> + %% Line 797 + apply 'filter_report'/2 + (T, Msg) + end + %% Line 799 + <[{Key,RegExp,'re'}|T],Msg> when 'true' -> + %% Line 800 + case call 'proplists':'get_value' + (Key, Msg) of + %% Line 801 + <'undefined'> when 'true' -> + %% Line 802 + 'false' + %% Line 803 + when 'true' -> + let <_4> = + call %% Line 804 + 'io_lib':%% Line 804 + 'format' + (%% Line 804 + [126|[116|[112]]], %% Line 804 + [Value|[]]) + in let = + call %% Line 804 + 'lists':%% Line 804 + 'flatten' + (_4) + in %% Line 805 + case apply 'run_re'/2 + (Subject, RegExp) of + %% Line 806 + <'match'> when 'true' -> + %% Line 807 + apply 'filter_report'/2 + (T, Msg) + %% Line 808 + <_18> when 'true' -> + 'false' + end + end + %% Line 811 + <[{Key,RegExp,'re','no'}|T],Msg> when 'true' -> + %% Line 812 + case call 'proplists':'get_value' + (Key, Msg) of + %% Line 813 + <'undefined'> when 'true' -> + %% Line 814 + 'true' + %% Line 815 + when 'true' -> + let <_8> = + call %% Line 816 + 'io_lib':%% Line 816 + 'format' + (%% Line 816 + [126|[116|[112]]], %% Line 816 + [Value|[]]) + in let = + call %% Line 816 + 'lists':%% Line 816 + 'flatten' + (_8) + in %% Line 817 + case apply 'run_re'/2 + (Subject, RegExp) of + %% Line 818 + <'match'> when 'true' -> + 'false' + %% Line 819 + <_19> when 'true' -> + apply 'filter_report'/2 + (T, Msg) + end + end + ( <_13,_12> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_13,_12}) + -| [{'function_name',{'filter_report',2}}] ) + -| ['compiler_generated'] ) + end +'get_compare_dates'/2 = + %% Line 823 + fun (_0,_1) -> + %% Line 824 + case call 'application':'get_env' + ('sasl', 'utc_log') of + %% Line 825 + <{'ok','true'}> when 'true' -> + let <_3> = + apply %% Line 826 + 'local_time_to_universal_time'/1 + (_0) + in let <_2> = + apply %% Line 827 + 'local_time_to_universal_time'/1 + (_1) + in %% Line 826 + {_3,_2} + %% Line 828 + <_7> when 'true' -> + %% Line 829 + {_0,_1} + end +'get_compare_dates'/3 = + %% Line 831 + fun (_0,_1,_2) -> + %% Line 832 + case call 'application':'get_env' + ('sasl', 'utc_log') of + %% Line 833 + <{'ok','true'}> when 'true' -> + let <_5> = + apply %% Line 834 + 'local_time_to_universal_time'/1 + (_0) + in let <_4> = + apply %% Line 835 + 'local_time_to_universal_time'/1 + (_1) + in let <_3> = + apply %% Line 836 + 'local_time_to_universal_time'/1 + (_2) + in %% Line 834 + {_5,_4,_3} + %% Line 837 + <_10> when 'true' -> + %% Line 838 + {_0,_1,_2} + end +'compare_dates'/2 = + %% Line 841 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + %% Line 842 + case apply 'get_compare_dates'/2 + (Date, CompareDate) of + <{Date2,DateFrom}> when 'true' -> + let <_4> = + call %% Line 843 + 'calendar':%% Line 843 + 'datetime_to_gregorian_seconds' + (%% Line 843 + Date2) + in let <_3> = + call %% Line 844 + 'calendar':%% Line 844 + 'datetime_to_gregorian_seconds' + (%% Line 844 + DateFrom) + in %% Line 843 + call 'erlang':'>=' + (_4, _3) + ( <_2> when 'true' -> + primop 'match_fail' + ({'badmatch',_2}) + -| ['compiler_generated'] ) + end + %% Line 845 + when 'true' -> + %% Line 846 + case apply 'get_compare_dates'/2 + (Date, CompareDate) of + <{Date2,DateTo}> when 'true' -> + let <_7> = + call %% Line 847 + 'calendar':%% Line 847 + 'datetime_to_gregorian_seconds' + (%% Line 847 + Date2) + in let <_6> = + call %% Line 848 + 'calendar':%% Line 848 + 'datetime_to_gregorian_seconds' + (%% Line 848 + DateTo) + in %% Line 847 + call 'erlang':'=<' + (_7, _6) + ( <_5> when 'true' -> + primop 'match_fail' + ({'badmatch',_5}) + -| ['compiler_generated'] ) + end + %% Line 849 + when 'true' -> + %% Line 850 + case apply 'get_compare_dates'/3 + (Date, From, To) of + <{Date2,DateFrom,DateTo}> when 'true' -> + let <_11> = + call %% Line 851 + 'calendar':%% Line 851 + 'datetime_to_gregorian_seconds' + (%% Line 851 + Date2) + in let <_10> = + call %% Line 852 + 'calendar':%% Line 852 + 'datetime_to_gregorian_seconds' + (%% Line 852 + DateFrom) + in %% Line 853 + ( case <> of + ( <> + when call 'erlang':'>=' + (_11, + _10) -> + let <_13> = + call %% Line 854 + 'calendar':%% Line 854 + 'datetime_to_gregorian_seconds' + (%% Line 854 + Date2) + in let <_12> = + call %% Line 855 + 'calendar':%% Line 855 + 'datetime_to_gregorian_seconds' + (%% Line 855 + DateTo) + in %% Line 854 + call 'erlang':'=<' + (_13, _12) + -| ['compiler_generated'] ) + ( <> when 'true' -> + 'false' + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_8> when 'true' -> + primop 'match_fail' + ({'badmatch',_8}) + -| ['compiler_generated'] ) + end + ( <_16,_15> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_16,_15}) + -| [{'function_name',{'compare_dates',2}}] ) + -| ['compiler_generated'] ) + end +'print_filter_report'/5 = + %% Line 857 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + <{Date,Msg},Filters,Device,Abort,Log> when 'true' -> + %% Line 858 + case Msg of + <{_X_D,M}> when 'true' -> + %% Line 859 + case M of + <{_16,_17,M2}> when 'true' -> + %% Line 860 + case M2 of + %% Line 861 + <{_18,_19,Report}> when 'true' -> + %% Line 862 + case apply 'filter_report'/2 + (Filters, Report) of + %% Line 863 + <'true'> when 'true' -> + let <_7> = + catch + %% Line 864 + call 'rb_format_supp':'print' + (Date, Msg, Device) + in %% Line 864 + case _7 of + %% Line 865 + <{'EXIT',_20}> when 'true' -> + %% Line 866 + apply 'handle_bad_form'/5 + (Date, Msg, Device, Abort, Log) + %% Line 867 + <_21> when 'true' -> + %% Line 868 + {'proceed',Device} + end + %% Line 870 + <_22> when 'true' -> + %% Line 871 + {'proceed',Device} + end + %% Line 873 + <_23> when 'true' -> + %% Line 874 + {'proceed',Device} + end + ( <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + -| ['compiler_generated'] ) + end + ( <_5> when 'true' -> + primop 'match_fail' + ({'badmatch',_5}) + -| ['compiler_generated'] ) + end + ( <_15,_14,_13,_12,_11> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_15,_14,_13,_12,_11}) + -| [{'function_name',{'print_filter_report',5}}] ) + -| ['compiler_generated'] ) + end +'read_rep'/5 = + %% Line 877 + fun (_0,_1,_2,_3,_4) -> + %% Line 878 + case apply 'read_rep_msg'/2 + (_0, _1) of + %% Line 879 + <{Date,Msg}> when 'true' -> + let <_5> = + catch + %% Line 880 + call 'rb_format_supp':'print' + (Date, Msg, _2) + in %% Line 880 + case _5 of + %% Line 881 + <{'EXIT',_13}> when 'true' -> + %% Line 882 + apply 'handle_bad_form'/5 + (Date, Msg, _2, _3, _4) + %% Line 883 + <_14> when 'true' -> + %% Line 884 + {'proceed',_2} + end + %% Line 886 + <_15> when 'true' -> + do %% Line 887 + call 'io':'format' + ([114|[98|[58|[32|[67|[97|[110|[110|[111|[116|[32|[114|[101|[97|[100|[32|[102|[114|[111|[109|[32|[102|[105|[108|[101|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 888 + {'proceed',_2} + end +'handle_bad_form'/5 = + %% Line 891 + fun (_0,_1,_2,_3,_4) -> + do %% Line 892 + call 'io':'format' + ([114|[98|[58|[32|[69|[82|[82|[79|[82|[33|[32|[65|[32|[114|[101|[112|[111|[114|[116|[32|[111|[110|[32|[98|[97|[100|[32|[102|[111|[114|[109|[32|[119|[97|[115|[32|[101|[110|[99|[111|[117|[110|[116|[101|[114|[101|[100|[46|[32|[73|[116|[32|[99|[97|[110|[110|[111|[116|[32|[98|[101|[32|[112|[114|[105|[110|[116|[101|[100|[32|[116|[111|[32|[116|[104|[101|[32|[108|[111|[103|[46|[126|[110|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]) + do %% Line 894 + call 'io':'format' + ([68|[101|[116|[97|[105|[108|[115|[58|[126|[110|[126|[112|[32|[126|[116|[112|[126|[110|[126|[110]]]]]]]]]]]]]]]]]]]], [_0|[_1|[]]]) + let <_6> = + apply %% Line 895 + 'open_log_file'/1 + (_4) + in %% Line 895 + case <_3,_2,_6> of + %% Line 896 + <'true','standard_io','standard_io'> when 'true' -> + do %% Line 897 + call 'io':'format' + ([114|[98|[58|[32|[76|[111|[103|[103|[105|[110|[103|[32|[97|[98|[111|[114|[116|[101|[100|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]) + %% Line 898 + {'abort',_2} + %% Line 899 + <'false','standard_io','standard_io'> when 'true' -> + do %% Line 900 + call 'io':'format' + ([114|[98|[58|[32|[76|[111|[103|[103|[105|[110|[103|[32|[114|[101|[115|[117|[109|[101|[100|[46|[46|[46|[126|[110|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 901 + {'proceed',_2} + %% Line 902 + <_18,_19,( 'standard_io' + -| ['compiler_generated'] )> when 'true' -> + do %% Line 903 + call 'io':'format' + ([114|[98|[58|[32|[67|[97|[110|[32|[110|[111|[116|[32|[114|[101|[111|[112|[101|[110|[32|[126|[116|[112|[46|[32|[76|[111|[103|[103|[105|[110|[103|[32|[97|[98|[111|[114|[116|[101|[100|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], [_4|[]]) + %% Line 904 + {'abort',_2} + %% Line 905 + <( 'true' + -| ['compiler_generated'] ),_20,NewDevice> when 'true' -> + do %% Line 906 + call 'io':'format' + (NewDevice, %% Line 907 + [126|[110|[126|[110|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[32|[82|[66|[32|[69|[82|[82|[79|[82|[32|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[126|[110|[65|[32|[114|[101|[112|[111|[114|[116|[32|[111|[110|[32|[98|[97|[100|[32|[102|[111|[114|[109|[32|[119|[97|[115|[32|[101|[110|[99|[111|[117|[110|[116|[101|[114|[101|[100|[32|[104|[101|[114|[101|[32|[97|[110|[100|[32|[116|[104|[101|[32|[108|[111|[103|[103|[105|[110|[103|[126|[110|[112|[114|[111|[99|[101|[115|[115|[32|[119|[97|[115|[32|[97|[98|[111|[114|[116|[101|[100|[46|[32|[78|[111|[116|[101|[32|[116|[104|[97|[116|[32|[116|[104|[101|[114|[101|[32|[109|[97|[121|[32|[119|[101|[108|[108|[32|[98|[101|[32|[114|[101|[109|[97|[105|[110|[105|[110|[103|[126|[110|[114|[101|[112|[111|[114|[116|[115|[32|[116|[104|[97|[116|[32|[104|[97|[118|[101|[110|[39|[116|[32|[121|[101|[116|[32|[98|[101|[101|[110|[32|[108|[111|[103|[103|[101|[100|[46|[32|[80|[108|[101|[97|[115|[101|[32|[115|[101|[101|[32|[116|[104|[101|[32|[114|[98|[126|[110|[109|[97|[110|[117|[97|[108|[32|[102|[111|[114|[32|[109|[111|[114|[101|[32|[105|[110|[102|[111|[46|[126|[110|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[42|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 912 + []) + do %% Line 913 + call 'io':'format' + ([114|[98|[58|[32|[76|[111|[103|[103|[105|[110|[103|[32|[97|[98|[111|[114|[116|[101|[100|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]) + %% Line 914 + {'abort',NewDevice} + %% Line 915 + <( 'false' + -| ['compiler_generated'] ),_21,NewDevice> when 'true' -> + do %% Line 916 + call 'io':'format' + (NewDevice, %% Line 917 + [126|[110|[32|[32|[32|[42|[42|[42|[42|[42|[42|[42|[42|[42|[32|[82|[66|[58|[32|[85|[78|[80|[82|[73|[78|[84|[65|[66|[76|[69|[32|[82|[69|[80|[79|[82|[84|[32|[42|[42|[42|[42|[42|[42|[42|[42|[126|[110|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 917 + []) + do %% Line 918 + call 'io':'format' + ([114|[98|[58|[32|[76|[111|[103|[103|[105|[110|[103|[32|[114|[101|[115|[117|[109|[101|[100|[46|[46|[46|[126|[110|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]) + %% Line 919 + {'proceed',NewDevice} + ( <( _22 + -| ['compiler_generated'] ),( _23 + -| ['compiler_generated'] ),( _24 + -| ['compiler_generated'] )> when 'true' -> + let <_12> = {( _22 + -| ['compiler_generated'] ),( _23 + -| ['compiler_generated'] ),( _24 + -| ['compiler_generated'] )} + in primop 'match_fail' + ({'case_clause',_12}) + -| ['compiler_generated'] ) + end +'read_rep_msg'/2 = + %% Line 922 + fun (_0,_1) -> + %% Line 923 + case call 'file':'position' + (_0, {'bof',_1}) of + <{'ok',_11}> when 'true' -> + let <_3> = + catch + %% Line 925 + apply 'read_report'/1 + (_0) + in let <_6> = + case _3 of + %% Line 926 + <{'ok',Report}> when 'true' -> + %% Line 927 + case apply 'get_short_descr'/1 + (Report) of + <{_X_ShortDescr,Date}> when 'true' -> + %% Line 928 + {Date,Report} + ( <_4> when 'true' -> + primop 'match_fail' + ({'badmatch',_4}) + -| ['compiler_generated'] ) + end + %% Line 929 + <_12> when 'true' -> + 'error' + end + in %% Line 931 + case call 'file':'close' + (_0) of + <'ok'> when 'true' -> + _6 + ( <_8> when 'true' -> + primop 'match_fail' + ({'badmatch',_8}) + -| ['compiler_generated'] ) + end + ( <_2> when 'true' -> + primop 'match_fail' + ({'badmatch',_2}) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('rb') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('rb', _0) +end \ No newline at end of file diff --git a/test/data/sasl/rb_format_supp.core b/test/data/sasl/rb_format_supp.core new file mode 100644 index 0000000..37d3cd2 --- /dev/null +++ b/test/data/sasl/rb_format_supp.core @@ -0,0 +1,379 @@ +module 'rb_format_supp' ['module_info'/0, + 'module_info'/1, + 'print'/3] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[114|[98|[95|[102|[111|[114|[109|[97|[116|[95|[115|[117|[112|[112|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]]],1}]] +'print'/3 = + %% Line 29 + fun (_0,_1,_2) -> + %% Line 35 + case _1 of + <{_X_Time,Rep}> when 'true' -> + %% Line 36 + case Rep of + %% Line 37 + <{'error_report',_X_GL,{Pid,'crash_report',CrashReport}}> when 'true' -> + let
= + apply %% Line 38 + 'format_h'/4 + (79, %% Line 38 + [67|[82|[65|[83|[72|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]]], %% Line 38 + Pid, _0) + in let <_6> = + apply %% Line 42 + 'format_c'/1 + (%% Line 42 + CrashReport) + in do %% Line 39 + call 'format_lib_supp':'print_info' + (_2, 79, %% Line 41 + [{'header',Header}|_6]) + %% Line 43 + 'true' + %% Line 44 + <{'error_report',_X_GL,{Pid,'supervisor_report',SupReport}}> when 'true' -> + let
= + apply %% Line 45 + 'format_h'/4 + (79, %% Line 45 + [83|[85|[80|[69|[82|[86|[73|[83|[79|[82|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]]]]]]]], %% Line 45 + Pid, _0) + in let <_8> = + apply %% Line 49 + 'format_s'/1 + (%% Line 49 + SupReport) + in do %% Line 46 + call 'format_lib_supp':'print_info' + (_2, 79, %% Line 48 + [{'header',Header}|_8]) + %% Line 50 + 'true' + %% Line 51 + <{'error_report',_X_GL,{Pid,_X_Type,Report1}}> when 'true' -> + let
= + apply %% Line 52 + 'format_h'/4 + (79, %% Line 52 + [69|[82|[82|[79|[82|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]]], %% Line 52 + Pid, _0) + in do %% Line 53 + call 'format_lib_supp':'print_info' + (_2, 79, %% Line 55 + [{'header',Header}|%% Line 56 + [{'data',Report1}|[]]]) + %% Line 57 + 'true' + %% Line 58 + <{'info_report',_X_GL,{Pid,'progress',SupProgress}}> when 'true' -> + let
= + apply %% Line 59 + 'format_h'/4 + (79, %% Line 59 + [80|[82|[79|[71|[82|[69|[83|[83|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]]]]]], %% Line 59 + Pid, _0) + in let <_11> = + apply %% Line 63 + 'format_p'/1 + (%% Line 63 + SupProgress) + in %% Line 60 + call 'format_lib_supp':'print_info' + (_2, 79, %% Line 62 + [{'header',Header}|_11]) + %% Line 64 + <{'info_report',_X_GL,{Pid,_X_Type,Report1}}> when 'true' -> + let
= + apply %% Line 65 + 'format_h'/4 + (79, %% Line 65 + [73|[78|[70|[79|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]], %% Line 65 + Pid, _0) + in do %% Line 66 + call 'format_lib_supp':'print_info' + (_2, 79, %% Line 68 + [{'header',Header}|%% Line 69 + [{'data',Report1}|[]]]) + %% Line 70 + 'true' + %% Line 71 + <{'warning_report',_X_GL,{Pid,_X_Type,Report1}}> when 'true' -> + let
= + apply %% Line 72 + 'format_h'/4 + (79, %% Line 72 + [87|[65|[82|[78|[73|[78|[71|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]]]]], %% Line 72 + Pid, _0) + in do %% Line 73 + call 'format_lib_supp':'print_info' + (_2, 79, %% Line 75 + [{'header',Header}|%% Line 76 + [{'data',Report1}|[]]]) + %% Line 77 + 'true' + %% Line 78 + <{'error',_X_GL,{Pid,Format,Args}}> when 'true' -> + let
= + apply %% Line 79 + 'format_h'/4 + (79, %% Line 79 + [69|[82|[82|[79|[82|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]]], %% Line 79 + Pid, _0) + in do %% Line 80 + call 'format_lib_supp':'print_info' + (_2, 79, %% Line 82 + [{'header',Header}|[]]) + %% Line 83 + call 'io':'format' + (_2, Format, Args) + %% Line 84 + <{'info_msg',_X_GL,{Pid,Format,Args}}> when 'true' -> + let
= + apply %% Line 85 + 'format_h'/4 + (79, %% Line 85 + [73|[78|[70|[79|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]], %% Line 85 + Pid, _0) + in do %% Line 86 + call 'format_lib_supp':'print_info' + (_2, 79, %% Line 88 + [{'header',Header}|[]]) + %% Line 89 + call 'io':'format' + (_2, Format, Args) + %% Line 90 + <{'warning_msg',_X_GL,{Pid,Format,Args}}> when 'true' -> + let
= + apply %% Line 91 + 'format_h'/4 + (79, %% Line 91 + [87|[65|[82|[78|[73|[78|[71|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]]]]], %% Line 91 + Pid, _0) + in do %% Line 92 + call 'format_lib_supp':'print_info' + (_2, 79, %% Line 94 + [{'header',Header}|[]]) + %% Line 95 + call 'io':'format' + (_2, Format, Args) + %% Line 96 + <{Type,_X_GL,TypeReport}> when 'true' -> + let = + call %% Line 97 + 'misc_supp':%% Line 97 + 'modifier' + (_2) + in let <_18> = + call %% Line 98 + 'erlang':%% Line 98 + '++' + (%% Line 98 + Modifier, %% Line 98 + [119|[62|[32|[126|[115|[126|[110]]]]]]]) + in let <_19> = + call %% Line 98 + 'erlang':%% Line 98 + '++' + (%% Line 98 + [126|[110|[73|[110|[102|[111|[32|[116|[121|[112|[101|[32|[60|[126]]]]]]]]]]]]]], _18) + in do %% Line 98 + call 'io':'format' + (_2, _19, %% Line 99 + [Type|[_0|[]]]) + let <_20> = + call %% Line 100 + 'erlang':%% Line 100 + '++' + (%% Line 100 + Modifier, %% Line 100 + [112]) + in let <_21> = + [126|_20] + in %% Line 100 + call 'io':'format' + (_2, _21, [TypeReport|[]]) + %% Line 101 + <_29> when 'true' -> + let = + call %% Line 102 + 'misc_supp':%% Line 102 + 'modifier' + (_2) + in do %% Line 103 + call 'io':'format' + ([126|[110|[80|[114|[105|[110|[116|[105|[110|[103|[32|[105|[110|[102|[111|[32|[111|[102|[32|[117|[110|[107|[110|[111|[119|[110|[32|[116|[121|[112|[101|[46|[46|[46|[32|[126|[115|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 104 + [_0|[]]) + let <_23> = + call %% Line 105 + 'erlang':%% Line 105 + '++' + (%% Line 105 + Modifier, %% Line 105 + [112]) + in let <_24> = + [126|_23] + in %% Line 105 + call 'io':'format' + (_2, _24, [_1|[]]) + end + ( <_4> when 'true' -> + primop 'match_fail' + ({'badmatch',_4}) + -| ['compiler_generated'] ) + end +'format_h'/4 = + %% Line 109 + fun (_0,_1,_2,_3) -> + let <_4> = + call %% Line 110 + 'io_lib':%% Line 110 + 'format' + (%% Line 110 + [126|[115|[32|[32|[126|[119]]]]]], %% Line 110 + [_1|[_2|[]]]) + in let = + call %% Line 110 + 'lists':%% Line 110 + 'flatten' + (_4) + in let = + call %% Line 111 + 'string':%% Line 111 + 'length' + (_3) + in let = + call %% Line 112 + 'erlang':%% Line 112 + '-' + (_0, %% Line 112 + DateLen) + in let = + call %% Line 113 + 'lists':%% Line 113 + 'concat' + (%% Line 113 + [[126|[45]]|[HeaderLen|[[115|[126]]|[DateLen|[[115]]]]]]) + in %% Line 114 + call 'io_lib':'format' + (Format, [NHeader|[_3|[]]]) +'format_c'/1 = + %% Line 120 + fun (_0) -> + case _0 of + <[OwnReport|[LinkReport|[]]]> when 'true' -> + let <_1> = + apply %% Line 122 + 'format_neighbours'/1 + (%% Line 122 + LinkReport) + in %% Line 121 + [{'items',{[67|[114|[97|[115|[104|[105|[110|[103|[32|[112|[114|[111|[99|[101|[115|[115]]]]]]]]]]]]]]]],OwnReport}}|%% Line 122 + [_1|[]]] + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'format_c',1}}] ) + -| ['compiler_generated'] ) + end +'format_neighbours'/1 = + %% Line 124 + fun (_0) -> + case _0 of + <[Data|Rest]> when 'true' -> + let <_1> = + apply %% Line 127 + 'format_neighbours'/1 + (%% Line 127 + Rest) + in %% Line 125 + [{'newline',1}|%% Line 126 + [{'items',{[78|[101|[105|[103|[104|[98|[111|[117|[114|[32|[112|[114|[111|[99|[101|[115|[115]]]]]]]]]]]]]]]]],Data}}|_1]] + %% Line 128 + <[]> when 'true' -> + [] + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'format_neighbours',1}}] ) + -| ['compiler_generated'] ) + end +'format_s'/1 = + %% Line 133 + fun (_0) -> + let = + apply %% Line 134 + 'get_opt'/2 + (%% Line 134 + 'supervisor', _0) + in let = + apply %% Line 135 + 'get_opt'/2 + (%% Line 135 + 'errorContext', _0) + in let = + apply %% Line 136 + 'get_opt'/2 + (%% Line 136 + 'reason', _0) + in let = + apply %% Line 137 + 'get_opt'/2 + (%% Line 137 + 'offender', _0) + in let <_7> = + fun (_5) -> + %% Line 143 + apply 'transform_mfa'/1 + (_5) + in let <_8> = + call %% Line 143 + 'lists':%% Line 143 + 'map' + (_7, %% Line 143 + ChildInfo) + in %% Line 138 + [{'data',[{[82|[101|[112|[111|[114|[116|[105|[110|[103|[32|[115|[117|[112|[101|[114|[118|[105|[115|[111|[114]]]]]]]]]]]]]]]]]]]],SuperName}|[]]}|%% Line 139 + [{'newline',1}|%% Line 140 + [{'items',{[67|[104|[105|[108|[100|[32|[112|[114|[111|[99|[101|[115|[115]]]]]]]]]]]]],%% Line 141 + [{'errorContext',ErrorContext}|%% Line 142 + [{'reason',Reason}|_8]]}}|%% Line 143 + []]]] +'transform_mfa'/1 = + %% Line 145 + fun (_0) -> + case _0 of + <{'mfa',Value}> when 'true' -> + {'start_function',Value} + %% Line 146 + when 'true' -> + X + end +'format_p'/1 = + %% Line 151 + fun (_0) -> + %% Line 152 + [{'data',_0}|[]] +'get_opt'/2 = + %% Line 154 + fun (_0,_1) -> + %% Line 155 + case call 'lists':'keysearch' + (_0, 1, _1) of + %% Line 156 + <{'value',{_X_Key,Val}}> when 'true' -> + Val + %% Line 157 + <_5> when 'true' -> + 'undefined' + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('rb_format_supp') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('rb_format_supp', _0) +end \ No newline at end of file diff --git a/test/data/sasl/release_handler.core b/test/data/sasl/release_handler.core new file mode 100644 index 0000000..c288aa6 --- /dev/null +++ b/test/data/sasl/release_handler.core @@ -0,0 +1,6761 @@ +module 'release_handler' ['check_install_release'/1, + 'check_install_release'/2, + 'code_change'/3, + 'create_RELEASES'/1, + 'create_RELEASES'/2, + 'create_RELEASES'/4, + 'do_copy_file'/2, + 'do_copy_files'/1, + 'do_copy_files'/2, + 'do_ensure_RELEASES'/1, + 'do_remove_files'/1, + 'do_rename_files'/1, + 'do_write_file'/2, + 'do_write_file'/3, + 'do_write_release'/3, + 'downgrade_app'/2, + 'downgrade_app'/3, + 'downgrade_script'/3, + 'eval_appup_script'/4, + 'handle_call'/3, + 'handle_cast'/2, + 'handle_info'/2, + 'init'/1, + 'install_file'/2, + 'install_release'/1, + 'install_release'/2, + 'make_permanent'/1, + 'module_info'/0, + 'module_info'/1, + 'new_emulator_upgrade'/2, + 'reboot_old_release'/1, + 'remove_file'/1, + 'remove_release'/1, + 'set_removed'/1, + 'set_unpacked'/2, + 'start_link'/0, + 'terminate'/2, + 'unpack_release'/1, + 'upgrade_app'/2, + 'upgrade_script'/2, + 'which_releases'/0, + 'which_releases'/1] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[114|[101|[108|[101|[97|[115|[101|[95|[104|[97|[110|[100|[108|[101|[114|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]]]],1}], + %% Line 21 + 'behaviour' = + %% Line 21 + ['gen_server'], + %% Line 1 + 'file' = + %% Line 1 + [{[47|[117|[115|[114|[47|[108|[111|[99|[97|[108|[47|[67|[101|[108|[108|[97|[114|[47|[101|[114|[108|[97|[110|[103|[47|[50|[50|[46|[50|[47|[108|[105|[98|[47|[101|[114|[108|[97|[110|[103|[47|[108|[105|[98|[47|[107|[101|[114|[110|[101|[108|[45|[54|[46|[53|[46|[49|[47|[105|[110|[99|[108|[117|[100|[101|[47|[102|[105|[108|[101|[46|[104|[114|[108]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],1}], + %% Line 25 + 'record' = + %% Line 25 + [{'file_info',[{'typed_record_field',{'record_field',26,{'atom',26,'size'}},{'type',26,'union',[{'type',26,'non_neg_integer',[]}|[{'atom',26,'undefined'}]]}}|[{'typed_record_field',{'record_field',27,{'atom',27,'type'}},{'type',27,'union',[{'atom',27,'device'}|[{'atom',27,'directory'}|[{'atom',27,'other'}|[{'atom',27,'regular'}|[{'atom',27,'symlink'}|[{'atom',28,'undefined'}]]]]]]}}|[{'typed_record_field',{'record_field',29,{'atom',29,'access'}},{'type',29,'union',[{'atom',29,'read'}|[{'atom',29,'write'}|[{'atom',29,'read_write'}|[{'atom',29,'none'}|[{'atom',29,'undefined'}]]]]]}}|[{'typed_record_field',{'record_field',30,{'atom',30,'atime'}},{'type',30,'union',[{'remote_type',30,[{'atom',30,'file'}|[{'atom',30,'date_time'}|[[]]]]}|[{'type',30,'non_neg_integer',[]}|[{'atom',30,'undefined'}]]]}}|[{'typed_record_field',{'record_field',34,{'atom',34,'mtime'}},{'type',34,'union',[{'remote_type',34,[{'atom',34,'file'}|[{'atom',34,'date_time'}|[[]]]]}|[{'type',34,'non_neg_integer',[]}|[{'atom',34,'undefined'}]]]}}|[{'typed_record_field',{'record_field',36,{'atom',36,'ctime'}},{'type',36,'union',[{'remote_type',36,[{'atom',36,'file'}|[{'atom',36,'date_time'}|[[]]]]}|[{'type',36,'non_neg_integer',[]}|[{'atom',36,'undefined'}]]]}}|[{'typed_record_field',{'record_field',42,{'atom',42,'mode'}},{'type',42,'union',[{'type',42,'non_neg_integer',[]}|[{'atom',42,'undefined'}]]}}|[{'typed_record_field',{'record_field',46,{'atom',46,'links'}},{'type',46,'union',[{'type',46,'non_neg_integer',[]}|[{'atom',46,'undefined'}]]}}|[{'typed_record_field',{'record_field',49,{'atom',49,'major_device'}},{'type',49,'union',[{'type',49,'non_neg_integer',[]}|[{'atom',49,'undefined'}]]}}|[{'typed_record_field',{'record_field',55,{'atom',55,'minor_device'}},{'type',55,'union',[{'type',55,'non_neg_integer',[]}|[{'atom',55,'undefined'}]]}}|[{'typed_record_field',{'record_field',57,{'atom',57,'inode'}},{'type',57,'union',[{'type',57,'non_neg_integer',[]}|[{'atom',57,'undefined'}]]}}|[{'typed_record_field',{'record_field',58,{'atom',58,'uid'}},{'type',58,'union',[{'type',58,'non_neg_integer',[]}|[{'atom',58,'undefined'}]]}}|[{'typed_record_field',{'record_field',59,{'atom',59,'gid'}},{'type',59,'union',[{'type',59,'non_neg_integer',[]}|[{'atom',59,'undefined'}]]}}]]]]]]]]]]]]]}], + %% Line 62 + 'record' = + %% Line 62 + [{'file_descriptor',[{'typed_record_field',{'record_field',63,{'atom',63,'module'}},{'type',63,'module',[]}}|[{'typed_record_field',{'record_field',64,{'atom',64,'data'}},{'type',64,'term',[]}}]]}], + %% Line 24 + 'file' = + %% Line 24 + [{[115|[114|[99|[47|[114|[101|[108|[101|[97|[115|[101|[95|[104|[97|[110|[100|[108|[101|[114|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]]]],24}], + %% Line 48 + 'record' = + %% Line 48 + [{'state',[{'record_field',48,{'atom',48,'unpurged'},{'nil',48}}|[{'record_field',49,{'atom',49,'root'}}|[{'record_field',50,{'atom',50,'rel_dir'}}|[{'record_field',51,{'atom',51,'releases'}}|[{'record_field',52,{'atom',52,'timer'}}|[{'record_field',53,{'atom',53,'start_prg'}}|[{'record_field',54,{'atom',54,'masters'},{'atom',54,'false'}}|[{'record_field',55,{'atom',55,'client_dir'},{'atom',55,'false'}}|[{'record_field',56,{'atom',56,'static_emulator'},{'atom',56,'false'}}|[{'record_field',57,{'atom',57,'pre_sync_nodes'},{'nil',57}}]]]]]]]]]]}], + %% Line 76 + 'record' = + %% Line 76 + [{'release',[{'record_field',76,{'atom',76,'name'}}|[{'record_field',76,{'atom',76,'vsn'}}|[{'record_field',76,{'atom',76,'erts_vsn'}}|[{'record_field',76,{'atom',76,'libs'},{'nil',76}}|[{'record_field',76,{'atom',76,'status'}}]]]]]}]] +'start_link'/0 = + %% Line 142 + fun () -> + %% Line 143 + call 'gen_server':'start_link' + ({'local','release_handler'}, 'release_handler', [], []) +'unpack_release'/1 = + %% Line 158 + fun (_0) -> + %% Line 159 + apply 'call'/1 + ({'unpack_release',_0}) +'check_install_release'/1 = + %% Line 176 + fun (_0) -> + %% Line 177 + apply 'check_install_release'/2 + (_0, []) +'check_install_release'/2 = + %% Line 179 + fun (_0,_1) -> + %% Line 180 + case apply 'check_check_install_options'/2 + (_1, 'false') of + %% Line 181 + <{'ok',Purge}> when 'true' -> + %% Line 182 + apply 'call'/1 + ({'check_install_release',_0,Purge}) + %% Line 183 + when 'true' -> + %% Line 184 + Error + end +'check_check_install_options'/2 = + %% Line 187 + fun (_0,_1) -> + case <_0,_1> of + <['purge'|Opts],_4> when 'true' -> + %% Line 188 + apply 'check_check_install_options'/2 + (Opts, 'true') + %% Line 189 + <[Illegal|_5],_X_Purge> when 'true' -> + %% Line 190 + {'error',{'illegal_option',Illegal}} + %% Line 191 + <[],Purge> when 'true' -> + %% Line 192 + {'ok',Purge} + ( <_3,_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3,_2}) + -| [{'function_name',{'check_check_install_options',2}}] ) + -| ['compiler_generated'] ) + end +'install_release'/1 = + %% Line 210 + fun (_0) -> + %% Line 211 + apply 'call'/1 + ({'install_release',_0,'restart',[]}) +'install_release'/2 = + %% Line 214 + fun (_0,_1) -> + %% Line 215 + case apply 'check_install_options'/3 + (_1, 'restart', []) of + %% Line 216 + <{'ok',ErrorAction,InstallOpt}> when 'true' -> + %% Line 217 + apply 'call'/1 + ({'install_release',_0,ErrorAction,InstallOpt}) + %% Line 218 + when 'true' -> + %% Line 219 + Error + end +'check_install_options'/3 = + %% Line 222 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <[Opt|Opts],ErrAct,InstOpts> when 'true' -> + %% Line 223 + case apply 'install_option'/1 + (Opt) of + %% Line 224 + <{'error_action',EAct}> when 'true' -> + %% Line 225 + apply 'check_install_options'/3 + (Opts, EAct, InstOpts) + %% Line 226 + <'true'> when 'true' -> + %% Line 227 + apply 'check_install_options'/3 + (Opts, ErrAct, [Opt|InstOpts]) + %% Line 228 + <'false'> when 'true' -> + %% Line 229 + {'error',{'illegal_option',Opt}} + ( <_3> when 'true' -> + primop 'match_fail' + ({'case_clause',_3}) + -| ['compiler_generated'] ) + end + %% Line 231 + <[],ErrAct,InstOpts> when 'true' -> + %% Line 232 + {'ok',ErrAct,InstOpts} + ( <_6,_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5,_4}) + -| [{'function_name',{'check_install_options',3}}] ) + -| ['compiler_generated'] ) + end +'install_option'/1 = + %% Line 234 + fun (_0) -> + case _0 of + when 'true' -> + Opt + %% Line 235 + when 'true' -> + Opt + %% Line 236 + <{'code_change_timeout',TimeOut}> when 'true' -> + %% Line 237 + apply 'check_timeout'/1 + (TimeOut) + %% Line 238 + <{'suspend_timeout',TimeOut}> when 'true' -> + %% Line 239 + apply 'check_timeout'/1 + (TimeOut) + %% Line 240 + <{'update_paths',Bool}> + when let <_1> = + call 'erlang':'=:=' + (Bool, 'true') + in let <_2> = + call 'erlang':'=:=' + (Bool, 'false') + in call 'erlang':'or' + (_1, _2) -> + %% Line 241 + 'true' + %% Line 242 + <_X_Opt> when 'true' -> + 'false' + end +'check_timeout'/1 = + %% Line 244 + fun (_0) -> + case _0 of + <'infinity'> when 'true' -> + 'true' + %% Line 245 + + when let <_1> = + call 'erlang':'is_integer' + (_0) + in let <_2> = + call 'erlang':'>' + (_0, 0) + in call 'erlang':'and' + (_1, _2) -> + 'true' + %% Line 246 + <_X_Else> when 'true' -> + 'false' + end +'new_emulator_upgrade'/2 = + %% Line 256 + fun (_0,_1) -> + let = + apply %% Line 257 + 'call'/1 + (%% Line 257 + {'install_release',_0,'reboot',_1}) + in do %% Line 258 + call 'error_logger':'info_msg' + (%% Line 259 + [126|[119|[58|[105|[110|[115|[116|[97|[108|[108|[95|[114|[101|[108|[101|[97|[115|[101|[40|[126|[112|[44|[126|[112|[41|[32|[99|[111|[109|[112|[108|[101|[116|[101|[100|[32|[97|[102|[116|[101|[114|[32|[110|[111|[100|[101|[32|[114|[101|[115|[116|[97|[114|[116|[32|[119|[105|[116|[104|[32|[110|[101|[119|[32|[101|[109|[117|[108|[97|[116|[111|[114|[32|[118|[101|[114|[115|[105|[111|[110|[126|[110|[82|[101|[115|[117|[108|[116|[58|[32|[126|[112|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 260 + ['release_handler'|[_0|[_1|[Result|[]]]]]) + %% Line 261 + Result +'make_permanent'/1 = + %% Line 272 + fun (_0) -> + %% Line 273 + apply 'call'/1 + ({'make_permanent',_0}) +'reboot_old_release'/1 = + %% Line 278 + fun (_0) -> + %% Line 279 + apply 'call'/1 + ({'reboot_old_release',_0}) +'remove_release'/1 = + %% Line 288 + fun (_0) -> + %% Line 289 + apply 'call'/1 + ({'remove_release',_0}) +'set_unpacked'/2 = + %% Line 307 + fun (_0,_1) -> + %% Line 308 + apply 'call'/1 + ({'set_unpacked',_0,_1}) +'set_removed'/1 = + %% Line 317 + fun (_0) -> + %% Line 318 + apply 'call'/1 + ({'set_removed',_0}) +'install_file'/2 = + %% Line 328 + fun (_0,_1) -> + case <_0,_1> of + + when call 'erlang':'is_list' + (File) -> + %% Line 329 + apply 'call'/1 + ({'install_file',File,Vsn}) + ( <_3,_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3,_2}) + -| [{'function_name',{'install_file',2}}] ) + -| ['compiler_generated'] ) + end +'which_releases'/0 = + %% Line 335 + fun () -> + %% Line 336 + apply 'call'/1 + ('which_releases') +'which_releases'/1 = + %% Line 342 + fun (_0) -> + let = + apply %% Line 343 + 'which_releases'/0 + () + in %% Line 344 + apply 'get_releases_with_status'/3 + (Releases, _0, []) +'check_script'/2 = + %% Line 349 + fun (_0,_1) -> + %% Line 350 + call 'release_handler_1':'check_script' + (_0, _1) +'eval_script'/5 = + %% Line 367 + fun (_0,_1,_2,_3,_4) -> + catch + %% Line 368 + call 'release_handler_1':'eval_script' + (_0, _1, _2, _3, _4) +'create_RELEASES'/1 = + %% Line 375 + fun (_0) -> + case _0 of + <[Root|[RelFile|LibDirs]]> when 'true' -> + let <_1> = + call %% Line 376 + 'filename':%% Line 376 + 'join' + (%% Line 376 + Root, %% Line 376 + [114|[101|[108|[101|[97|[115|[101|[115]]]]]]]]) + in %% Line 376 + apply 'create_RELEASES'/4 + (Root, _1, RelFile, LibDirs) + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'create_RELEASES',1}}] ) + -| ['compiler_generated'] ) + end +'create_RELEASES'/2 = + %% Line 378 + fun (_0,_1) -> + let <_2> = + call %% Line 379 + 'filename':%% Line 379 + 'join' + (_0, %% Line 379 + [114|[101|[108|[101|[97|[115|[101|[115]]]]]]]]) + in %% Line 379 + apply 'create_RELEASES'/4 + (_0, _2, _1, []) +'create_RELEASES'/4 = + %% Line 381 + fun (_0,_1,_2,_3) -> + let <_4> = + catch + %% Line 382 + apply 'check_rel'/4 + (_0, _2, _3, 'false') + in %% Line 382 + case _4 of + %% Line 383 + <_@r0 = {'error',Reason}> when 'true' -> + %% Line 384 + _@r0 + %% Line 385 + when 'true' -> + %% Line 386 + case Rel of + <{'release',_14,_15,_16,_17,_18}> when 'true' -> + let <_7> = + call 'erlang':'setelement' + (6, Rel, 'permanent') + in catch + %% Line 387 + apply 'write_releases'/3 + (_1, [_7|[]], 'false') + ( <_19> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + end +'upgrade_app'/2 = + %% Line 400 + fun (_0,_1) -> + %% Line 401 + try + apply 'upgrade_script'/2 + (_0, _1) + of <_2> -> + case _2 of + %% Line 402 + <{'ok',NewVsn,Script}> when 'true' -> + %% Line 403 + apply 'eval_appup_script'/4 + (_0, NewVsn, _1, Script) + ( <_3> when 'true' -> + primop 'match_fail' + ({'try_clause',_3}) + -| ['compiler_generated'] ) + end + catch <_6,_5,_4> -> + %% Line 405 + case <_6,_5,_4> of + <( 'throw' + -| ['compiler_generated'] ),Reason,_9> when 'true' -> + %% Line 406 + {'error',Reason} + ( <_10,_11,_12> when 'true' -> + primop 'raise' + (_12, _11) + -| ['compiler_generated'] ) + end +'downgrade_app'/2 = + %% Line 422 + fun (_0,_1) -> + let <_2> = + call %% Line 423 + 'filename':%% Line 423 + 'basename' + (_1) + in %% Line 423 + case call 'string':'lexemes' + (_2, [45]) of + %% Line 424 + <[_X_AppS|[OldVsn|[]]]> when 'true' -> + %% Line 425 + apply 'downgrade_app'/3 + (_0, OldVsn, _1) + %% Line 426 + <_6> when 'true' -> + %% Line 427 + {'error',{'unknown_version',_0}} + end +'downgrade_app'/3 = + %% Line 429 + fun (_0,_1,_2) -> + %% Line 430 + try + apply 'downgrade_script'/3 + (_0, _1, _2) + of <_3> -> + case _3 of + %% Line 431 + <{'ok',Script}> when 'true' -> + %% Line 432 + apply 'eval_appup_script'/4 + (_0, _1, _2, Script) + ( <_4> when 'true' -> + primop 'match_fail' + ({'try_clause',_4}) + -| ['compiler_generated'] ) + end + catch <_7,_6,_5> -> + %% Line 434 + case <_7,_6,_5> of + <( 'throw' + -| ['compiler_generated'] ),Reason,_11> when 'true' -> + %% Line 435 + {'error',Reason} + ( <_12,_13,_14> when 'true' -> + primop 'raise' + (_14, _13) + -| ['compiler_generated'] ) + end +'upgrade_script'/2 = + %% Line 438 + fun (_0,_1) -> + let = + apply %% Line 439 + 'ensure_running'/1 + (_0) + in let = + call %% Line 440 + 'code':%% Line 440 + 'lib_dir' + (_0) + in %% Line 441 + case apply 'find_script'/4 + (_0, _1, OldVsn, 'up') of + <{NewVsn,Script}> when 'true' -> + let = + apply %% Line 442 + 'read_app'/3 + (_0, %% Line 442 + OldVsn, %% Line 442 + OldDir) + in let = + apply %% Line 443 + 'read_app'/3 + (_0, %% Line 443 + NewVsn, _1) + in %% Line 444 + case call 'systools_rc':'translate_scripts' + ('up', %% Line 445 + [Script|[]], %% Line 445 + [NewAppl|[]], %% Line 445 + [OldAppl|[]]) of + %% Line 446 + <{'ok',LowLevelScript}> when 'true' -> + %% Line 447 + {'ok',NewVsn,LowLevelScript} + %% Line 448 + <{'error',_X_SystoolsRC,Reason}> when 'true' -> + %% Line 449 + call 'erlang':'throw' + (Reason) + ( <_7> when 'true' -> + primop 'match_fail' + ({'case_clause',_7}) + -| ['compiler_generated'] ) + end + ( <_4> when 'true' -> + primop 'match_fail' + ({'badmatch',_4}) + -| ['compiler_generated'] ) + end +'downgrade_script'/3 = + %% Line 452 + fun (_0,_1,_2) -> + let = + apply %% Line 453 + 'ensure_running'/1 + (_0) + in let = + call %% Line 454 + 'code':%% Line 454 + 'lib_dir' + (_0) + in %% Line 455 + case apply 'find_script'/4 + (_0, NewDir, _1, 'down') of + <{_12,Script}> + when call 'erlang':'=:=' + (_12, + NewVsn) -> + let = + apply %% Line 456 + 'read_app'/3 + (_0, _1, _2) + in let = + apply %% Line 457 + 'read_app'/3 + (_0, %% Line 457 + NewVsn, %% Line 457 + NewDir) + in %% Line 458 + case call 'systools_rc':'translate_scripts' + ('dn', %% Line 459 + [Script|[]], %% Line 459 + [OldAppl|[]], %% Line 459 + [NewAppl|[]]) of + %% Line 460 + <_@r0 = {'ok',LowLevelScript}> when 'true' -> + %% Line 461 + _@r0 + %% Line 462 + <{'error',_X_SystoolsRC,Reason}> when 'true' -> + %% Line 463 + call 'erlang':'throw' + (Reason) + ( <_8> when 'true' -> + primop 'match_fail' + ({'case_clause',_8}) + -| ['compiler_generated'] ) + end + ( <_5> when 'true' -> + primop 'match_fail' + ({'badmatch',_5}) + -| ['compiler_generated'] ) + end +'eval_appup_script'/4 = + %% Line 466 + fun (_0,_1,_2,_3) -> + let = + call %% Line 467 + 'application_controller':%% Line 467 + 'prep_config_change' + () + in let = + apply %% Line 468 + 'read_appspec'/2 + (_0, _2) + in let = + call %% Line 469 + 'release_handler_1':%% Line 469 + 'eval_script' + (_3, %% Line 470 + [], %% Line 471 + [{_0,_1,_2}|[]], %% Line 472 + [{_0,_1,_2}|[]], %% Line 473 + []) + in do %% Line 474 + case Res of + %% Line 475 + <{'ok',_X_Unpurged}> when 'true' -> + do %% Line 476 + call 'application_controller':'change_application_data' + (AppSpecL, []) + %% Line 477 + call 'application_controller':'config_change' + (EnvBefore) + %% Line 478 + <_X_Res> when 'true' -> + 'ok' + end + %% Line 481 + Res +'ensure_running'/1 = + %% Line 483 + fun (_0) -> + let <_1> = + call %% Line 484 + 'application':%% Line 484 + 'which_applications' + () + in %% Line 484 + case call 'lists':'keysearch' + (_0, 1, _1) of + %% Line 485 + <{'value',{_X_App,_X_Descr,Vsn}}> when 'true' -> + %% Line 486 + Vsn + %% Line 487 + <'false'> when 'true' -> + %% Line 488 + call 'erlang':'throw' + ({'app_not_running',_0}) + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end +'find_script'/4 = + %% Line 491 + fun (_0,_1,_2,_3) -> + let <_4> = + call %% Line 492 + 'erlang':%% Line 492 + 'atom_to_list' + (_0) + in let <_5> = + call %% Line 492 + 'erlang':%% Line 492 + '++' + (_4, %% Line 492 + [46|[97|[112|[112|[117|[112]]]]]]) + in let = + call %% Line 492 + 'filename':%% Line 492 + 'join' + (%% Line 492 + [_1|[[101|[98|[105|[110]]]]|[_5|[]]]]) + in %% Line 493 + case call 'file':'consult' + (Appup) of + %% Line 494 + <{'ok',[{NewVsn,UpFromScripts,DownToScripts}|[]]}> when 'true' -> + let <_8> = + case _3 of + %% Line 496 + <'up'> when 'true' -> + UpFromScripts + %% Line 497 + <'down'> when 'true' -> + DownToScripts + ( <_7> when 'true' -> + %% Line 495 + primop 'match_fail' + ({'case_clause',_7}) + -| ['compiler_generated'] ) + end + in %% Line 499 + case call 'systools_relup':'appup_search_for_version' + (_2, _8) of + %% Line 500 + <{'ok',Script}> when 'true' -> + %% Line 501 + {NewVsn,Script} + %% Line 502 + <'error'> when 'true' -> + %% Line 503 + call 'erlang':'throw' + ({'version_not_in_appup',_2}) + ( <_10> when 'true' -> + primop 'match_fail' + ({'case_clause',_10}) + -| ['compiler_generated'] ) + end + %% Line 505 + <{'error','enoent'}> when 'true' -> + %% Line 506 + call 'erlang':'throw' + ('no_appup_found') + %% Line 507 + <{'error',Reason}> when 'true' -> + %% Line 508 + call 'erlang':'throw' + (Reason) + ( <_11> when 'true' -> + primop 'match_fail' + ({'case_clause',_11}) + -| ['compiler_generated'] ) + end +'read_app'/3 = + %% Line 511 + fun (_0,_1,_2) -> + let = + call %% Line 512 + 'erlang':%% Line 512 + 'atom_to_list' + (_0) + in let <_4> = + call %% Line 513 + 'filename':%% Line 513 + 'join' + (_2, %% Line 513 + [101|[98|[105|[110]]]]) + in let = + [_4|%% Line 513 + []] + in %% Line 514 + case call 'systools_make':'read_application' + (AppS, _1, Path, []) of + %% Line 515 + <{'ok',Appl}> when 'true' -> + %% Line 516 + Appl + %% Line 517 + <{'error',{'not_found',_X_AppFile}}> when 'true' -> + %% Line 518 + call 'erlang':'throw' + ({'no_app_found',_1,_2}) + %% Line 519 + <{'error',Reason}> when 'true' -> + %% Line 520 + call 'erlang':'throw' + (Reason) + ( <_6> when 'true' -> + primop 'match_fail' + ({'case_clause',_6}) + -| ['compiler_generated'] ) + end +'read_appspec'/2 = + %% Line 523 + fun (_0,_1) -> + let = + call %% Line 524 + 'erlang':%% Line 524 + 'atom_to_list' + (_0) + in let <_3> = + call %% Line 525 + 'filename':%% Line 525 + 'join' + (_1, %% Line 525 + [101|[98|[105|[110]]]]) + in let = + [_3|%% Line 525 + []] + in let <_5> = + call %% Line 526 + 'erlang':%% Line 526 + '++' + (%% Line 526 + AppS, %% Line 526 + [46|[97|[112|[112]]]]) + in %% Line 526 + case call 'file':'path_consult' + (Path, _5) of + %% Line 527 + <{'ok',AppSpecL,_X_File}> when 'true' -> + %% Line 528 + AppSpecL + %% Line 529 + <{'error',Reason}> when 'true' -> + %% Line 530 + call 'erlang':'throw' + (Reason) + ( <_6> when 'true' -> + primop 'match_fail' + ({'case_clause',_6}) + -| ['compiler_generated'] ) + end +'call'/1 = + %% Line 536 + fun (_0) -> + %% Line 537 + call 'gen_server':'call' + ('release_handler', _0, 'infinity') +'init'/1 = + %% Line 543 + fun (_0) -> + case _0 of + <[]> when 'true' -> + %% Line 544 + case call 'init':'get_argument' + ('root') of + <{'ok',[[Root|[]]|[]]}> when 'true' -> + %% Line 545 + case apply 'is_client'/0 + () of + <{CliDir,Masters}> when 'true' -> + let <_5> = + case %% Line 547 + call 'application':'get_env' + ('sasl', 'releases_dir') of + %% Line 548 + <'undefined'> when 'true' -> + %% Line 549 + case call 'os':'getenv' + ([82|[69|[76|[68|[73|[82]]]]]]) of + %% Line 550 + <'false'> when 'true' -> + %% Line 551 + case <> of + %% Line 552 + <> + when call 'erlang':'=:=' + (CliDir, + 'false') -> + %% Line 553 + call 'filename':'join' + ([Root|[[114|[101|[108|[101|[97|[115|[101|[115]]]]]]]]]]) + %% Line 554 + <> when 'true' -> + %% Line 555 + call 'filename':'join' + ([CliDir|[[114|[101|[108|[101|[97|[115|[101|[115]]]]]]]]]]) + end + %% Line 557 + when 'true' -> + %% Line 558 + RELDIR + end + %% Line 560 + <{'ok',Dir}> when 'true' -> + %% Line 561 + Dir + ( <_4> when 'true' -> + %% Line 547 + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end + in let <_7> = + call %% Line 564 + 'filename':%% Line 564 + 'join' + (_5, %% Line 564 + [82|[69|[76|[69|[65|[83|[69|[83]]]]]]]]) + in let <_10> = + case %% Line 564 + apply 'consult'/2 + (_7, Masters) of + %% Line 565 + <{'ok',[Term|[]]}> when 'true' -> + %% Line 566 + apply 'transform_release'/3 + (_5, Term, Masters) + %% Line 567 + <_20> when 'true' -> + %% Line 568 + case call 'init':'script_id' + () of + <{Name,Vsn}> when 'true' -> + %% Line 569 + [{'release',Name,Vsn,'undefined',[],'permanent'}|[]] + ( <_8> when 'true' -> + primop 'match_fail' + ({'badmatch',_8}) + -| ['compiler_generated'] ) + end + end + in let <_14> = + case %% Line 572 + call 'application':'get_env' + ('start_prg') of + %% Line 573 + <{'ok',Found2}> + when call 'erlang':'is_list' + (Found2) -> + %% Line 574 + {'do_check',Found2} + %% Line 575 + <_21> when 'true' -> + let <_12> = + call %% Line 576 + 'filename':%% Line 576 + 'join' + (%% Line 576 + [Root|[[98|[105|[110]]]|[[115|[116|[97|[114|[116]]]]]]]]) + in %% Line 576 + {'no_check',_12} + end + in let <_17> = + case %% Line 579 + call 'application':'get_env' + ('static_emulator') of + %% Line 580 + <{'ok',SFlag}> + when call 'erlang':'is_atom' + (SFlag) -> + SFlag + %% Line 581 + <_22> when 'true' -> + 'false' + end + in %% Line 583 + {'ok',{'state',[],Root,_5,_10,'undefined',_14,%% Line 584 + Masters,%% Line 585 + CliDir,_17,[]}} + ( <_2> when 'true' -> + primop 'match_fail' + ({'badmatch',_2}) + -| ['compiler_generated'] ) + end + ( <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + -| ['compiler_generated'] ) + end + ( <_19> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_19}) + -| [{'function_name',{'init',1}}] ) + -| ['compiler_generated'] ) + end +'handle_call'/3 = + %% Line 587 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <{'unpack_release',ReleaseName},_X_From,S = {'state',_117,_118,_119,_120,_121,_122,_123,_124,_125,_126}> + when %% Line 588 + ( try + let <_7> = + call 'erlang':'element' + (8, S) + in call 'erlang':'=:=' + (_7, 'false') + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + let <_15> = + catch + %% Line 589 + ( case S of + ( <( {'state',_127,_rec1,_128,_129,_130,_131,_132,_133,_134,_135} + -| ['compiler_generated'] )> when 'true' -> + ( case S of + ( <( {'state',_137,_138,_rec2,_139,_140,_141,_142,_143,_144,_145} + -| ['compiler_generated'] )> when 'true' -> + %% Line 590 + ( case S of + ( <( {'state',_147,_148,_149,_rec3,_150,_151,_152,_153,_154,_155} + -| ['compiler_generated'] )> when 'true' -> + apply 'do_unpack_release'/4 + (_rec1, _rec2, ReleaseName, _rec3) + -| ['compiler_generated'] ) + ( <_156> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_146> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_136> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + in %% Line 589 + case _15 of + %% Line 591 + <{'ok',NewReleases,Vsn}> when 'true' -> + %% Line 592 + case S of + <{'state',_157,_158,_159,_160,_161,_162,_163,_164,_165,_166}> when 'true' -> + let <_18> = + call 'erlang':'setelement' + (5, S, NewReleases) + in {'reply',{'ok',Vsn},_18} + ( <_167> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 593 + <_@r0 = {'error',Reason}> when 'true' -> + %% Line 594 + {'reply',_@r0,S} + %% Line 595 + <{'EXIT',Reason}> when 'true' -> + %% Line 596 + {'reply',{'error',Reason},S} + ( <_19> when 'true' -> + primop 'match_fail' + ({'case_clause',_19}) + -| ['compiler_generated'] ) + end + %% Line 598 + <{'unpack_release',_X_ReleaseName},_X_From,S> when 'true' -> + %% Line 599 + {'reply',{'error','client_node'},S} + %% Line 601 + <{'check_install_release',Vsn,Purge},_X_From,S> when 'true' -> + let <_26> = + catch + %% Line 602 + ( case S of + ( <( {'state',_168,_169,_rec5,_170,_171,_172,_173,_174,_175,_176} + -| ['compiler_generated'] )> when 'true' -> + %% Line 604 + ( case S of + ( <( {'state',_178,_179,_180,_rec6,_181,_182,_183,_184,_185,_186} + -| ['compiler_generated'] )> when 'true' -> + %% Line 605 + ( case S of + ( <( {'state',_188,_189,_190,_191,_192,_193,_rec7,_194,_195,_196} + -| ['compiler_generated'] )> when 'true' -> + apply 'do_check_install_release'/5 + (_rec5, Vsn, _rec6, _rec7, %% Line 606 + Purge) + -| ['compiler_generated'] ) + ( <_197> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_187> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_177> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + in %% Line 602 + case _26 of + %% Line 607 + <_@r1 = {'ok',CurrentVsn,Descr}> when 'true' -> + %% Line 608 + {'reply',_@r1,S} + %% Line 609 + <_@r2 = {'error',Reason}> when 'true' -> + %% Line 610 + {'reply',_@r2,S} + %% Line 611 + <{'EXIT',Reason}> when 'true' -> + %% Line 612 + {'reply',{'error',Reason},S} + ( <_27> when 'true' -> + primop 'match_fail' + ({'case_clause',_27}) + -| ['compiler_generated'] ) + end + %% Line 615 + <{'install_release',Vsn,ErrorAction,Opts},From,S> when 'true' -> + let = + apply %% Line 616 + 'resend_sync_nodes'/1 + (%% Line 616 + S) + in let <_29> = + catch + %% Line 617 + apply 'do_install_release'/3 + (S, Vsn, Opts) + in %% Line 617 + case _29 of + %% Line 618 + <{'ok',NewReleases,[],CurrentVsn,Descr}> when 'true' -> + %% Line 619 + case NS of + <{'state',_198,_199,_200,_201,_202,_203,_204,_205,_206,_207}> when 'true' -> + let <_32> = + call 'erlang':'setelement' + (5, NS, NewReleases) + in {'reply',{'ok',CurrentVsn,Descr},_32} + ( <_208> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 620 + <{'ok',NewReleases,Unpurged,CurrentVsn,Descr}> when 'true' -> + %% Line 622 + ( case S of + ( <( {'state',_209,_210,_211,_212,_rec9,_213,_214,_215,_216,_217} + -| ['compiler_generated'] )> when 'true' -> + let <_37> = + case _rec9 of + %% Line 623 + <'undefined'> when 'true' -> + %% Line 624 + case call 'timer':'send_interval' + (10000, 'timeout') of + <{'ok',Ref}> when 'true' -> + %% Line 625 + Ref + ( <_35> when 'true' -> + primop 'match_fail' + ({'badmatch',_35}) + -| ['compiler_generated'] ) + end + %% Line 626 + when 'true' -> + Ref + end + in %% Line 628 + case NS of + <{'state',_219,_220,_221,_222,_223,_224,_225,_226,_227,_228}> when 'true' -> + let <_40> = + call %% Line 629 + 'erlang':%% Line 629 + 'setelement' + (%% Line 629 + 6, NS, _37) + in let <_41> = + call 'erlang':'setelement' + (5, _40, NewReleases) + in let <_43> = + call 'erlang':'setelement' + (2, _41, Unpurged) + in %% Line 630 + {'reply',{'ok',CurrentVsn,Descr},_43} + ( <_229> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_218> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 631 + <_@r3 = {'error',Reason}> when 'true' -> + %% Line 632 + {'reply',_@r3,NS} + %% Line 633 + <{'restart_emulator',CurrentVsn,Descr}> when 'true' -> + do %% Line 634 + call 'gen_server':'reply' + (From, {'ok',CurrentVsn,Descr}) + do %% Line 635 + call 'init':'reboot' + () + %% Line 636 + {'noreply',NS} + %% Line 637 + <{'restart_new_emulator',CurrentVsn,Descr}> when 'true' -> + do %% Line 638 + call 'gen_server':'reply' + (From, {'continue_after_restart',CurrentVsn,Descr}) + do %% Line 639 + call 'init':'reboot' + () + %% Line 640 + {'noreply',NS} + %% Line 641 + <{'EXIT',Reason}> when 'true' -> + do %% Line 642 + call 'io':'format' + ([114|[101|[108|[101|[97|[115|[101|[95|[104|[97|[110|[100|[108|[101|[114|[58|[105|[110|[115|[116|[97|[108|[108|[95|[114|[101|[108|[101|[97|[115|[101|[40|[86|[115|[110|[61|[126|[116|[112|[32|[79|[112|[116|[115|[61|[126|[116|[112|[41|[32|[102|[97|[105|[108|[101|[100|[44|[32|[82|[101|[97|[115|[111|[110|[61|[126|[116|[112|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 644 + [Vsn|[Opts|[Reason|[]]]]) + do %% Line 645 + call 'gen_server':'reply' + (From, {'error',Reason}) + do %% Line 646 + case ErrorAction of + %% Line 647 + <'restart'> when 'true' -> + %% Line 648 + call 'init':'restart' + () + %% Line 649 + <'reboot'> when 'true' -> + %% Line 650 + call 'init':'reboot' + () + ( <_45> when 'true' -> + primop 'match_fail' + ({'case_clause',_45}) + -| ['compiler_generated'] ) + end + %% Line 652 + {'noreply',NS} + ( <_46> when 'true' -> + primop 'match_fail' + ({'case_clause',_46}) + -| ['compiler_generated'] ) + end + %% Line 655 + <{'make_permanent',Vsn},_X_From,S> when 'true' -> + let <_47> = + catch + %% Line 656 + apply 'do_make_permanent'/2 + (S, Vsn) + in %% Line 656 + case _47 of + %% Line 657 + <{'ok',Releases,Unpurged}> when 'true' -> + %% Line 658 + case S of + <{'state',_230,_231,_232,_233,_234,_235,_236,_237,_238,_239}> when 'true' -> + let <_49> = + call 'erlang':'setelement' + (5, S, Releases) + in let <_51> = + call 'erlang':'setelement' + (2, _49, Unpurged) + in {'reply','ok',_51} + ( <_240> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 659 + <_@r4 = {'error',Reason}> when 'true' -> + %% Line 660 + {'reply',_@r4,S} + %% Line 661 + <{'EXIT',Reason}> when 'true' -> + %% Line 662 + {'reply',{'error',Reason},S} + ( <_52> when 'true' -> + primop 'match_fail' + ({'case_clause',_52}) + -| ['compiler_generated'] ) + end + %% Line 665 + <{'reboot_old_release',Vsn},From,S> when 'true' -> + let <_53> = + catch + %% Line 666 + apply 'do_reboot_old_release'/2 + (S, Vsn) + in %% Line 666 + case _53 of + %% Line 667 + <'ok'> when 'true' -> + do %% Line 668 + call 'gen_server':'reply' + (From, 'ok') + do %% Line 669 + call 'init':'reboot' + () + %% Line 670 + {'noreply',S} + %% Line 671 + <_@r5 = {'error',Reason}> when 'true' -> + %% Line 672 + {'reply',_@r5,S} + %% Line 673 + <{'EXIT',Reason}> when 'true' -> + %% Line 674 + {'reply',{'error',Reason},S} + ( <_54> when 'true' -> + primop 'match_fail' + ({'case_clause',_54}) + -| ['compiler_generated'] ) + end + %% Line 677 + <{'remove_release',Vsn},_X_From,S = {'state',_241,_242,_243,_244,_245,_246,_247,_248,_249,_250}> + when %% Line 678 + ( try + let <_59> = + call 'erlang':'element' + (8, S) + in call 'erlang':'=:=' + (_59, 'false') + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + let <_67> = + catch + %% Line 679 + ( case S of + ( <( {'state',_251,_rec12,_252,_253,_254,_255,_256,_257,_258,_259} + -| ['compiler_generated'] )> when 'true' -> + ( case S of + ( <( {'state',_261,_262,_rec13,_263,_264,_265,_266,_267,_268,_269} + -| ['compiler_generated'] )> when 'true' -> + %% Line 680 + ( case S of + ( <( {'state',_271,_272,_273,_rec14,_274,_275,_276,_277,_278,_279} + -| ['compiler_generated'] )> when 'true' -> + apply 'do_remove_release'/4 + (_rec12, _rec13, Vsn, _rec14) + -| ['compiler_generated'] ) + ( <_280> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_270> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_260> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + in %% Line 679 + case _67 of + %% Line 681 + <{'ok',NewReleases}> when 'true' -> + %% Line 682 + case S of + <{'state',_281,_282,_283,_284,_285,_286,_287,_288,_289,_290}> when 'true' -> + let <_70> = + call 'erlang':'setelement' + (5, S, NewReleases) + in {'reply','ok',_70} + ( <_291> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 683 + <_@r6 = {'error',Reason}> when 'true' -> + %% Line 684 + {'reply',_@r6,S} + %% Line 685 + <{'EXIT',Reason}> when 'true' -> + %% Line 686 + {'reply',{'error',Reason},S} + ( <_71> when 'true' -> + primop 'match_fail' + ({'case_clause',_71}) + -| ['compiler_generated'] ) + end + %% Line 688 + <{'remove_release',_X_Vsn},_X_From,S> when 'true' -> + %% Line 689 + {'reply',{'error','client_node'},S} + %% Line 691 + <{'set_unpacked',RelFile,LibDirs},_X_From,S> when 'true' -> + %% Line 692 + ( case S of + ( <( {'state',_292,_rec16,_293,_294,_295,_296,_297,_298,_299,_300} + -| ['compiler_generated'] )> when 'true' -> + let <_81> = + catch + %% Line 693 + ( case S of + ( <( {'state',_302,_303,_rec17,_304,_305,_306,_307,_308,_309,_310} + -| ['compiler_generated'] )> when 'true' -> + %% Line 694 + ( case S of + ( <( {'state',_312,_313,_314,_rec18,_315,_316,_317,_318,_319,_320} + -| ['compiler_generated'] )> when 'true' -> + %% Line 695 + ( case S of + ( <( {'state',_322,_323,_324,_325,_326,_327,_rec19,_328,_329,_330} + -| ['compiler_generated'] )> when 'true' -> + apply 'do_set_unpacked'/6 + (_rec16, _rec17, RelFile, LibDirs, _rec18, _rec19) + -| ['compiler_generated'] ) + ( <_331> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_321> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_311> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + in %% Line 693 + case _81 of + %% Line 696 + <{'ok',NewReleases,Vsn}> when 'true' -> + %% Line 697 + case S of + <{'state',_332,_333,_334,_335,_336,_337,_338,_339,_340,_341}> when 'true' -> + let <_84> = + call 'erlang':'setelement' + (5, S, NewReleases) + in {'reply',{'ok',Vsn},_84} + ( <_342> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 698 + <_@r7 = {'error',Reason}> when 'true' -> + %% Line 699 + {'reply',_@r7,S} + %% Line 700 + <{'EXIT',Reason}> when 'true' -> + %% Line 701 + {'reply',{'error',Reason},S} + ( <_85> when 'true' -> + primop 'match_fail' + ({'case_clause',_85}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_301> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 704 + <{'set_removed',Vsn},_X_From,S> when 'true' -> + let <_92> = + catch + %% Line 705 + ( case S of + ( <( {'state',_343,_344,_rec21,_345,_346,_347,_348,_349,_350,_351} + -| ['compiler_generated'] )> when 'true' -> + %% Line 706 + ( case S of + ( <( {'state',_353,_354,_355,_rec22,_356,_357,_358,_359,_360,_361} + -| ['compiler_generated'] )> when 'true' -> + %% Line 707 + ( case S of + ( <( {'state',_363,_364,_365,_366,_367,_368,_rec23,_369,_370,_371} + -| ['compiler_generated'] )> when 'true' -> + apply 'do_set_removed'/4 + (_rec21, Vsn, _rec22, _rec23) + -| ['compiler_generated'] ) + ( <_372> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_362> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_352> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + in %% Line 705 + case _92 of + %% Line 708 + <{'ok',NewReleases}> when 'true' -> + %% Line 709 + case S of + <{'state',_373,_374,_375,_376,_377,_378,_379,_380,_381,_382}> when 'true' -> + let <_95> = + call 'erlang':'setelement' + (5, S, NewReleases) + in {'reply','ok',_95} + ( <_383> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 710 + <_@r8 = {'error',Reason}> when 'true' -> + %% Line 711 + {'reply',_@r8,S} + %% Line 712 + <{'EXIT',Reason}> when 'true' -> + %% Line 713 + {'reply',{'error',Reason},S} + ( <_96> when 'true' -> + primop 'match_fail' + ({'case_clause',_96}) + -| ['compiler_generated'] ) + end + %% Line 716 + <{'install_file',File,Vsn},_X_From,S> when 'true' -> + %% Line 718 + ( case S of + ( <( {'state',_384,_385,_386,_rec25,_387,_388,_389,_390,_391,_392} + -| ['compiler_generated'] )> when 'true' -> + let <_105> = + case call 'lists':'keysearch' + (Vsn, 3, _rec25) of + %% Line 719 + <{'value',_394}> when 'true' -> + %% Line 720 + ( case S of + ( <( {'state',_395,_396,_rec26,_397,_398,_399,_400,_401,_402,_403} + -| ['compiler_generated'] )> when 'true' -> + let = + call 'filename':'join' + ([_rec26|[Vsn|[]]]) + in catch + %% Line 721 + ( case S of + ( <( {'state',_405,_406,_407,_408,_409,_410,_rec27,_411,_412,_413} + -| ['compiler_generated'] )> when 'true' -> + apply 'copy_file'/3 + (File, Dir, _rec27) + -| ['compiler_generated'] ) + ( <_414> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_404> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 722 + <_415> when 'true' -> + %% Line 723 + {'error',{'no_such_release',Vsn}} + end + in %% Line 725 + {'reply',_105,S} + -| ['compiler_generated'] ) + ( <_393> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 727 + <'which_releases',_X_From,S> when 'true' -> + let <_112> = + fun (_110) -> + %% Line 728 + case _110 of + <{'release',Name,Vsn,_416,Libs,%% Line 729 + Status}> when 'true' -> + let <_109> = + apply %% Line 730 + 'mk_lib_name'/1 + (%% Line 730 + Libs) + in %% Line 730 + {Name,Vsn,_109,Status} + ( <_111> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_111}) + -| [{'function_name',{'-handle_call/3-fun-0-',1}}] ) + -| ['compiler_generated'] ) + end + in %% Line 731 + ( case S of + ( <( {'state',_417,_418,_419,_rec28,_420,_421,_422,_423,_424,_425} + -| ['compiler_generated'] )> when 'true' -> + let = + call 'lists':'map' + (_112, _rec28) + in %% Line 732 + {'reply',Reply,S} + -| ['compiler_generated'] ) + ( <_426> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_116,_115,_114> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_116,_115,_114}) + -| [{'function_name',{'handle_call',3}}] ) + -| ['compiler_generated'] ) + end +'mk_lib_name'/1 = + %% Line 734 + fun (_0) -> + case _0 of + <[{LibName,Vsn,_X_Dir}|T]> when 'true' -> + let <_1> = + call %% Line 735 + 'lists':%% Line 735 + 'concat' + (%% Line 735 + [LibName|[[45]|[Vsn|[]]]]) + in let <_2> = + apply %% Line 735 + 'mk_lib_name'/1 + (%% Line 735 + T) + in %% Line 735 + [_1|_2] + %% Line 736 + <[]> when 'true' -> + [] + ( <_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3}) + -| [{'function_name',{'mk_lib_name',1}}] ) + -| ['compiler_generated'] ) + end +'handle_info'/2 = + %% Line 738 + fun (_0,_1) -> + case <_0,_1> of + <'timeout',S> when 'true' -> + %% Line 739 + ( case S of + ( <( {'state',_rec29,_24,_25,_26,_27,_28,_29,_30,_31,_32} + -| ['compiler_generated'] )> when 'true' -> + case apply 'soft_purge'/1 + (_rec29) of + %% Line 740 + <[]> when 'true' -> + %% Line 741 + ( case S of + ( <( {'state',_34,_35,_36,_37,_rec30,_38,_39,_40,_41,_42} + -| ['result_not_wanted','compiler_generated'] )> when 'true' -> + do ( call ( 'timer' + -| ['result_not_wanted'] ):( 'cancel' + -| ['result_not_wanted'] ) + (_rec30) + -| ['result_not_wanted'] ) + %% Line 742 + case S of + <{'state',_44,_45,_46,_47,_48,_49,_50,_51,_52,_53}> when 'true' -> + let <_8> = + call 'erlang':'setelement' + (6, S, 'undefined') + in let <_10> = + call 'erlang':'setelement' + (2, _8, []) + in {'noreply',_10} + ( <_54> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_43> when 'true' -> + ( call ( 'erlang' + -| ['result_not_wanted','compiler_generated'] ):( 'error' + -| ['result_not_wanted','compiler_generated'] ) + (( {'badrecord','state'} + -| ['result_not_wanted','compiler_generated'] )) + -| ['result_not_wanted','compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 743 + when 'true' -> + %% Line 744 + case S of + <{'state',_55,_56,_57,_58,_59,_60,_61,_62,_63,_64}> when 'true' -> + let <_13> = + call 'erlang':'setelement' + (2, S, Unpurged) + in {'noreply',_13} + ( <_65> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + end + -| ['compiler_generated'] ) + ( <_33> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 747 + <_@r0 = {'sync_nodes',Id,Node},S> when 'true' -> + %% Line 748 + ( case S of + ( <( {'state',_66,_67,_68,_69,_70,_71,_72,_73,_74,_rec33} + -| ['compiler_generated'] )> when 'true' -> + let <_rec34> = + [%% Line 749 + _@r0|_rec33] + in %% Line 749 + case S of + <{'state',_76,_77,_78,_79,_80,_81,_82,_83,_84,_85}> when 'true' -> + let <_21> = + call 'erlang':'setelement' + (11, S, _rec34) + in {'noreply',_21} + ( <_86> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_75> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 751 + when 'true' -> + do %% Line 752 + call 'error_logger':'info_msg' + ([114|[101|[108|[101|[97|[115|[101|[95|[104|[97|[110|[100|[108|[101|[114|[58|[32|[103|[111|[116|[32|[117|[110|[107|[110|[111|[119|[110|[32|[109|[101|[115|[115|[97|[103|[101|[58|[32|[126|[112|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], [Msg|[]]) + %% Line 753 + {'noreply',State} + end +'terminate'/2 = + %% Line 755 + fun (_0,_1) -> + %% Line 756 + 'ok' +'handle_cast'/2 = + %% Line 758 + fun (_0,_1) -> + %% Line 759 + {'noreply',_1} +'code_change'/3 = + %% Line 760 + fun (_0,_1,_2) -> + %% Line 761 + {'ok',_1} +'is_client'/0 = + %% Line 766 + fun () -> + %% Line 767 + case call 'application':'get_env' + ('masters') of + %% Line 768 + <{'ok',Masters}> when 'true' -> + let = + call %% Line 769 + 'erlang':%% Line 769 + 'is_alive' + () + in %% Line 770 + case apply 'atom_list'/1 + (Masters) of + %% Line 771 + <'true'> + when call 'erlang':'=:=' + (Alive, + 'true') -> + %% Line 772 + case call 'application':'get_env' + ('client_directory') of + %% Line 773 + <{'ok',ClientDir}> when 'true' -> + %% Line 774 + case apply 'int_list'/1 + (ClientDir) of + %% Line 775 + <'true'> when 'true' -> + %% Line 776 + {ClientDir,Masters} + %% Line 777 + <_5> when 'true' -> + %% Line 778 + call 'erlang':'exit' + ({'bad_parameter','client_directory',%% Line 779 + ClientDir}) + end + %% Line 781 + <_6> when 'true' -> + %% Line 782 + {'false','false'} + end + %% Line 784 + <_7> when 'true' -> + %% Line 785 + call 'erlang':'exit' + ({'bad_parameter','masters',Masters}) + end + %% Line 787 + <_8> when 'true' -> + %% Line 788 + {'false','false'} + end +'atom_list'/1 = + %% Line 791 + fun (_0) -> + case _0 of + <[A|T]> + when call 'erlang':'is_atom' + (A) -> + apply 'atom_list'/1 + (T) + %% Line 792 + <[]> when 'true' -> + 'true' + %% Line 793 + <_2> when 'true' -> + 'false' + end +'int_list'/1 = + %% Line 795 + fun (_0) -> + case _0 of + <[I|T]> + when call 'erlang':'is_integer' + (I) -> + apply 'int_list'/1 + (T) + %% Line 796 + <[]> when 'true' -> + 'true' + %% Line 797 + <_2> when 'true' -> + 'false' + end +'resend_sync_nodes'/1 = + %% Line 799 + fun (_0) -> + let <_6> = + fun (_4) -> + let <_3> = + call %% Line 800 + 'erlang':%% Line 800 + 'self' + () + in %% Line 800 + call 'erlang':'!' + (_3, _4) + in %% Line 800 + ( case _0 of + ( <( {'state',_10,_11,_12,_13,_14,_15,_16,_17,_18,_rec36} + -| ['compiler_generated'] )> when 'true' -> + do call 'lists':'foreach' + (_6, _rec36) + %% Line 801 + case _0 of + <{'state',_20,_21,_22,_23,_24,_25,_26,_27,_28,_29}> when 'true' -> + call 'erlang':'setelement' + (11, _0, []) + ( <_30> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_19> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'soft_purge'/1 = + %% Line 803 + fun (_0) -> + let <_4> = + fun (_2) -> + %% Line 804 + case _2 of + <{Mod,_X_PostPurgeMethod}> when 'true' -> + %% Line 805 + case call 'code':'soft_purge' + (Mod) of + %% Line 806 + <'true'> when 'true' -> + 'false' + %% Line 807 + <'false'> when 'true' -> + 'true' + ( <_1> when 'true' -> + primop 'match_fail' + ({'case_clause',_1}) + -| ['compiler_generated'] ) + end + ( <_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3}) + -| [{'function_name',{'-soft_purge/1-fun-0-',1}}] ) + -| ['compiler_generated'] ) + end + in %% Line 804 + call 'lists':'filter' + (_4, _0) +'brutal_purge'/1 = + %% Line 812 + fun (_0) -> + let <_3> = + fun (_1) -> + %% Line 813 + case _1 of + <{Mod,'brutal_purge'}> when 'true' -> + do call 'code':'purge' + (Mod) + 'false' + %% Line 814 + <_5> when 'true' -> + 'true' + end + in %% Line 813 + call 'lists':'filter' + (_3, _0) +'do_unpack_release'/4 = + %% Line 830 + fun (_0,_1,_2,_3) -> + let <_4> = + call %% Line 831 + 'erlang':%% Line 831 + '++' + (_2, %% Line 831 + [46|[116|[97|[114|[46|[103|[122]]]]]]]) + in let = + call %% Line 831 + 'filename':%% Line 831 + 'join' + (_1, _4) + in do %% Line 832 + apply 'do_check_file'/2 + (Tar, 'regular') + let = + call %% Line 833 + 'erlang':%% Line 833 + '++' + (_2, %% Line 833 + [46|[114|[101|[108]]]]) + in let <_7> = + call %% Line 834 + ( 'filename' + -| ['result_not_wanted'] ):%% Line 834 + ( 'join' + -| ['result_not_wanted'] ) + (%% Line 834 + ( [114|[101|[108|[101|[97|[115|[101|[115]]]]]]]] + -| ['result_not_wanted'] ), %% Line 834 + Rel) + in do %% Line 834 + apply 'extract_rel_file'/3 + (_7, Tar, _0) + let = + call %% Line 835 + 'filename':%% Line 835 + 'join' + (_1, %% Line 835 + Rel) + in let = + apply %% Line 836 + 'check_rel'/3 + (_0, %% Line 836 + RelFile, %% Line 836 + 'false') + in %% Line 837 + case Release of + <{'release',_24,Vsn,_25,_26,_27}> when 'true' -> + do %% Line 838 + case call 'lists':'keysearch' + (Vsn, 3, _3) of + %% Line 839 + <{'value',_28}> when 'true' -> + call 'erlang':'throw' + ({'error',{'existing_release',Vsn}}) + %% Line 840 + <_29> when 'true' -> + 'ok' + end + do %% Line 842 + apply 'extract_tar'/2 + (_0, Tar) + %% Line 843 + case Release of + <{'release',_30,_31,_32,_33,_34}> when 'true' -> + let <_15> = + call 'erlang':'setelement' + (6, Release, 'unpacked') + in let = + [_15|_3] + in do %% Line 844 + apply 'write_releases'/3 + (_1, NewReleases, 'false') + let = + call %% Line 849 + 'filename':%% Line 849 + 'join' + (%% Line 849 + [_1|[Vsn|[]]]) + in do %% Line 850 + apply 'copy_file'/3 + (RelFile, Dir, 'false') + do %% Line 853 + ( call ( 'file' + -| ['result_not_wanted'] ):( 'delete' + -| ['result_not_wanted'] ) + (Tar) + -| ['result_not_wanted'] ) + do %% Line 854 + ( call ( 'file' + -| ['result_not_wanted'] ):( 'delete' + -| ['result_not_wanted'] ) + (RelFile) + -| ['result_not_wanted'] ) + %% Line 856 + {'ok',NewReleases,Vsn} + ( <_35> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + ( <_11> when 'true' -> + primop 'match_fail' + ({'badmatch',_11}) + -| ['compiler_generated'] ) + end +'check_rel'/3 = + %% Line 858 + fun (_0,_1,_2) -> + %% Line 859 + apply 'check_rel'/4 + (_0, _1, [], _2) +'check_rel'/4 = + %% Line 860 + fun (_0,_1,_2,_3) -> + %% Line 861 + case apply 'consult'/2 + (_1, _3) of + %% Line 862 + <{'ok',[RelData|[]]}> when 'true' -> + %% Line 863 + apply 'check_rel_data'/4 + (RelData, _0, _2, _3) + %% Line 864 + <{'ok',_9}> when 'true' -> + %% Line 865 + call 'erlang':'throw' + ({'error',{'bad_rel_file',_1}}) + %% Line 866 + <{'error',Reason}> + when call 'erlang':'is_tuple' + (Reason) -> + %% Line 867 + call 'erlang':'throw' + ({'error',{'bad_rel_file',_1}}) + %% Line 868 + <{'error',FileError}> when 'true' -> + %% Line 869 + call 'erlang':'throw' + ({'error',{FileError,_1}}) + ( <_4> when 'true' -> + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end +'check_rel_data'/4 = + %% Line 872 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <{'release',{Name,Vsn},{'erts',EVsn},Libs},Root,LibDirs,%% Line 873 + Masters> when 'true' -> + let <_13> = + fun (_11) -> + let = + call %% Line 876 + 'erlang':%% Line 876 + 'element' + (%% Line 876 + 1, %% Line 875 + _11) + in let = + call %% Line 877 + 'erlang':%% Line 877 + 'element' + (%% Line 877 + 2, %% Line 875 + _11) + in let = + call %% Line 878 + 'lists':%% Line 878 + 'concat' + (%% Line 878 + [Lib|[[45]|[LibVsn|[]]]]) + in let <_9> = + case %% Line 880 + call 'lists':'keysearch' + (Lib, 1, LibDirs) of + %% Line 881 + <{'value',{_X_Lib,_X_Vsn,Dir}}> when 'true' -> + let = + call %% Line 882 + 'filename':%% Line 882 + 'join' + (%% Line 882 + Dir, %% Line 882 + LibName) + in do %% Line 883 + apply 'check_path'/2 + (Path, Masters) + %% Line 884 + Path + %% Line 885 + <_19> when 'true' -> + %% Line 886 + call 'filename':'join' + ([Root|[[108|[105|[98]]]|[LibName|[]]]]) + end + in %% Line 888 + {Lib,LibVsn,_9} + in let = + call %% Line 875 + 'lists':%% Line 875 + 'map' + (_13, %% Line 890 + Libs) + in %% Line 891 + {'release',Name,Vsn,EVsn,%% Line 892 + Libs2,%% Line 892 + 'unpacking'} + %% Line 893 + when 'true' -> + %% Line 894 + call 'erlang':'throw' + ({'error',{'bad_rel_data',RelData}}) + end +'check_path'/1 = + %% Line 896 + fun (_0) -> + let <_1> = + call %% Line 897 + 'file':%% Line 897 + 'read_file_info' + (_0) + in %% Line 897 + apply 'check_path_response'/2 + (_0, _1) +'check_path'/2 = + %% Line 898 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + apply 'check_path'/1 + (Path) + %% Line 899 + when 'true' -> + apply 'check_path_master'/2 + (Masters, Path) + end +'check_path_master'/2 = + %% Line 906 + fun (_0,_1) -> + case <_0,_1> of + <[Master|Ms],Path> when 'true' -> + %% Line 907 + case call 'rpc':'call' + (Master, 'file', 'read_file_info', [Path|[]]) of + %% Line 908 + <{'badrpc',_5}> when 'true' -> + apply 'consult_master'/2 + (Ms, Path) + %% Line 909 + when 'true' -> + apply 'check_path_response'/2 + (Path, Res) + end + %% Line 911 + <[],_X_Path> when 'true' -> + %% Line 912 + {'error','no_master'} + ( <_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_4,_3}) + -| [{'function_name',{'check_path_master',2}}] ) + -| ['compiler_generated'] ) + end +'check_path_response'/2 = + %% Line 914 + fun (_0,_1) -> + case <_0,_1> of + <_X_Path,{'ok',Info = {'file_info',_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22}}> + when ( try + let <_6> = + call 'erlang':'element' + (3, Info) + in call 'erlang':'=:=' + (_6, 'directory') + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + %% Line 915 + 'ok' + %% Line 916 + when 'true' -> + %% Line 917 + call 'erlang':'throw' + ({'error',{'not_a_directory',Path}}) + %% Line 918 + when 'true' -> + %% Line 919 + call 'erlang':'throw' + ({'error',{'no_such_directory',Path}}) + ( <_9,_8> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_9,_8}) + -| [{'function_name',{'check_path_response',2}}] ) + -| ['compiler_generated'] ) + end +'do_check_install_release'/5 = + %% Line 921 + fun (_0,_1,_2,_3,_4) -> + %% Line 922 + case call 'lists':'keysearch' + (_1, 3, _2) of + %% Line 923 + <{'value',{'release',_32,_33,_34,_35,'current'}}> when 'true' -> + %% Line 924 + {'error',{'already_installed',_1}} + %% Line 925 + <{'value',Release}> when 'true' -> + let = + apply %% Line 926 + 'get_latest_release'/1 + (_2) + in let = + call %% Line 927 + 'filename':%% Line 927 + 'join' + (%% Line 927 + [_0|[_1|[]]]) + in let <_7> = + call %% Line 928 + 'filename':%% Line 928 + 'join' + (%% Line 928 + VsnDir, %% Line 928 + [115|[116|[97|[114|[116|[46|[98|[111|[111|[116]]]]]]]]]]) + in do %% Line 928 + apply 'check_file'/3 + (_7, 'regular', _3) + let <_8> = + call %% Line 929 + 'filename':%% Line 929 + 'join' + (%% Line 929 + VsnDir, %% Line 929 + [114|[101|[108|[117|[112]]]]]) + in let = + apply %% Line 929 + 'check_opt_file'/3 + (_8, %% Line 929 + 'regular', _3) + in let <_10> = + call %% Line 930 + 'filename':%% Line 930 + 'join' + (%% Line 930 + VsnDir, %% Line 930 + [115|[121|[115|[46|[99|[111|[110|[102|[105|[103]]]]]]]]]]) + in do %% Line 930 + apply 'check_opt_file'/3 + (_10, 'regular', _3) + %% Line 933 + ( case Release of + ( <( {'release',_36,_37,_38,_rec39,_39} + -| ['compiler_generated'] )> when 'true' -> + let <_17> = + fun (_15) -> + %% Line 934 + case _15 of + <{_X_Lib,_X_LibVsn,LibDir}> when 'true' -> + do %% Line 935 + apply 'check_file'/3 + (LibDir, 'directory', _3) + let = + call %% Line 936 + 'filename':%% Line 936 + 'join' + (%% Line 936 + LibDir, %% Line 936 + [101|[98|[105|[110]]]]) + in %% Line 937 + apply 'check_file'/3 + (Ebin, 'directory', _3) + ( <_16> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_16}) + -| [{'function_name',{'-do_check_install_release/5-fun-0-',1}}] ) + -| ['compiler_generated'] ) + end + in do %% Line 934 + call 'lists':'foreach' + (_17, _rec39) + %% Line 941 + case <> of + %% Line 942 + <> + when ( call 'erlang':'=:=' + (IsRelup, + 'true') + -| ['compiler_generated'] ) -> + %% Line 943 + case apply 'get_rh_script'/4 + (LatestRelease, Release, _0, _3) of + %% Line 944 + <{'ok',{CurrentVsn,Descr,Script}}> when 'true' -> + let <_18> = + catch + %% Line 945 + apply 'check_script'/2 + (Script, _rec39) + in %% Line 945 + case _18 of + %% Line 946 + <{'ok',SoftPurgeMods}> + when call 'erlang':'=:=' + (_4, + 'true') -> + %% Line 950 + case %% Line 951 + call 'release_handler_1':'check_old_processes' + (%% Line 952 + Script, %% Line 952 + 'brutal_purge') of + <{'ok',BrutalPurgeMods}> when 'true' -> + let <_23> = + fun (_21) -> + catch + %% Line 955 + call 'erlang':'purge_module' + (_21) + in let <_20> = + call %% Line 957 + 'erlang':%% Line 957 + '++' + (%% Line 957 + SoftPurgeMods, %% Line 957 + BrutalPurgeMods) + in do %% Line 953 + call 'lists':'foreach' + (_23, _20) + %% Line 958 + {'ok',CurrentVsn,Descr} + ( <_19> when 'true' -> + primop 'match_fail' + ({'badmatch',_19}) + -| ['compiler_generated'] ) + end + %% Line 959 + <{'ok',_41}> when 'true' -> + %% Line 960 + {'ok',CurrentVsn,Descr} + %% Line 961 + when 'true' -> + %% Line 962 + Else + end + %% Line 964 + when 'true' -> + %% Line 965 + Error + end + %% Line 967 + <> when 'true' -> + %% Line 968 + {'ok',_1,[]} + end + -| ['compiler_generated'] ) + ( <_40> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 970 + <_42> when 'true' -> + %% Line 971 + {'error',{'no_such_release',_1}} + end +'do_install_release'/3 = + %% Line 974 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <{'state',_28,%% Line 975 + RootDir,%% Line 976 + RelDir,%% Line 976 + Releases,_29,StartPrg,%% Line 977 + Masters,_30,%% Line 978 + Static,_31},%% Line 979 + Vsn,%% Line 979 + Opts> when 'true' -> + %% Line 980 + case call 'lists':'keysearch' + (Vsn, 3, Releases) of + %% Line 981 + <{'value',{'release',_32,_33,_34,_35,'current'}}> when 'true' -> + %% Line 982 + {'error',{'already_installed',Vsn}} + %% Line 983 + <{'value',Release}> when 'true' -> + let = + apply %% Line 984 + 'get_latest_release'/1 + (%% Line 984 + Releases) + in %% Line 985 + case apply 'get_rh_script'/4 + (LatestRelease, Release, RelDir, Masters) of + %% Line 986 + <{'ok',{_X_CurrentVsn,_X_Descr,['restart_new_emulator'|_X_Script]}}> + when %% Line 987 + call 'erlang':'=:=' + (Static, + 'true') -> + %% Line 988 + call 'erlang':'throw' + ('static_emulator') + %% Line 989 + <{'ok',{CurrentVsn,Descr,['restart_new_emulator'|_X_Script]}}> when 'true' -> + %% Line 997 + case %% Line 998 + apply 'new_emulator_make_tmp_release'/5 + (LatestRelease, Release, %% Line 999 + RelDir, %% Line 999 + Opts, %% Line 999 + Masters) of + <{TmpVsn,TmpRelease}> when 'true' -> + let = + [%% Line 1000 + TmpRelease|%% Line 1000 + Releases] + in do %% Line 1004 + apply 'prepare_restart_new_emulator'/7 + (StartPrg, RootDir, %% Line 1005 + RelDir, %% Line 1005 + TmpVsn, %% Line 1005 + TmpRelease, %% Line 1006 + NReleases, %% Line 1006 + Masters) + %% Line 1007 + {'restart_new_emulator',CurrentVsn,Descr} + ( <_4> when 'true' -> + primop 'match_fail' + ({'badmatch',_4}) + -| ['compiler_generated'] ) + end + %% Line 1008 + <{'ok',{CurrentVsn,Descr,Script}}> when 'true' -> + %% Line 1013 + ( case LatestRelease of + ( <( {'release',_36,_rec40,_37,_38,_39} + -| ['compiler_generated'] )> when 'true' -> + %% Line 1014 + ( case LatestRelease of + ( <( {'release',_41,_42,_rec41,_43,_44} + -| ['compiler_generated'] )> when 'true' -> + let = + apply 'new_emulator_rm_tmp_release'/6 + (_rec40, _rec41, %% Line 1015 + Vsn, %% Line 1015 + RelDir, %% Line 1015 + Releases, %% Line 1015 + Masters) + in do %% Line 1018 + apply 'mon_nodes'/1 + ('true') + let = + call %% Line 1019 + 'application_controller':%% Line 1019 + 'prep_config_change' + () + in let = + apply %% Line 1020 + 'change_appl_data'/3 + (%% Line 1020 + RelDir, %% Line 1020 + Release, %% Line 1020 + Masters) + in %% Line 1021 + ( case Release of + ( <( {'release',_46,_47,_48,_rec42,_49} + -| ['compiler_generated'] )> when 'true' -> + %% Line 1022 + ( case LatestRelease of + ( <( {'release',_51,_52,_53,_rec43,_54} + -| ['compiler_generated'] )> when 'true' -> + %% Line 1023 + ( case Release of + ( <( {'release',_56,_57,_58,_rec44,_59} + -| ['compiler_generated'] )> when 'true' -> + let = + apply 'get_new_libs'/2 + (_rec43, _rec44) + in %% Line 1024 + case apply 'eval_script'/5 + (Script, Apps, _rec42, NewLibs, Opts) of + %% Line 1025 + <{'ok',Unpurged}> when 'true' -> + do %% Line 1026 + call 'application_controller':'config_change' + (EnvBefore) + do %% Line 1027 + apply 'mon_nodes'/1 + ('false') + let = + apply %% Line 1028 + 'set_status'/3 + (%% Line 1028 + Vsn, %% Line 1028 + 'current', %% Line 1028 + NReleases) + in %% Line 1029 + {'ok',NReleases1,Unpurged,CurrentVsn,Descr} + %% Line 1030 + <'restart_emulator'> + when call 'erlang':'=:=' + (Static, + 'true') -> + %% Line 1031 + call 'erlang':'throw' + ('static_emulator') + %% Line 1032 + <'restart_emulator'> when 'true' -> + do %% Line 1033 + apply 'mon_nodes'/1 + ('false') + do %% Line 1034 + apply 'prepare_restart_new_emulator'/7 + (StartPrg, RootDir, %% Line 1035 + RelDir, %% Line 1035 + Vsn, %% Line 1035 + Release, %% Line 1036 + NReleases, %% Line 1036 + Masters) + %% Line 1037 + {'restart_emulator',CurrentVsn,Descr} + %% Line 1038 + when 'true' -> + do %% Line 1039 + call 'application_controller':'config_change' + (EnvBefore) + do %% Line 1040 + apply 'mon_nodes'/1 + ('false') + %% Line 1041 + Else + end + -| ['compiler_generated'] ) + ( <_60> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_55> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_50> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_45> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_40> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 1043 + when 'true' -> + %% Line 1044 + Error + end + %% Line 1046 + <_61> when 'true' -> + %% Line 1047 + {'error',{'no_such_release',Vsn}} + end + ( <_27,_26,_25> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_27,_26,_25}) + -| [{'function_name',{'do_install_release',3}}] ) + -| ['compiler_generated'] ) + end +'new_emulator_make_tmp_release'/5 = + %% Line 1050 + fun (_0,_1,_2,_3,_4) -> + %% Line 1051 + ( case _0 of + ( <( {'release',_31,_rec45,_32,_33,_34} + -| ['compiler_generated'] )> when 'true' -> + %% Line 1052 + ( case _1 of + ( <( {'release',_36,_rec46,_37,_38,_39} + -| ['compiler_generated'] )> when 'true' -> + let = + call %% Line 1053 + 'erlang':%% Line 1053 + '++' + (%% Line 1053 + [95|[95|[110|[101|[119|[95|[101|[109|[117|[108|[97|[116|[111|[114|[95|[95]]]]]]]]]]]]]]]], _rec45) + in %% Line 1054 + ( case _1 of + ( <( {'release',_41,_42,_43,_rec47,_44} + -| ['compiler_generated'] )> when 'true' -> + case apply 'get_base_libs'/1 + (_rec47) of + %% Line 1055 + <{'ok',{Kernel,Stdlib,Sasl},_46}> when 'true' -> + %% Line 1056 + ( case _0 of + ( <( {'release',_47,_48,_49,_rec48,_50} + -| ['compiler_generated'] )> when 'true' -> + case apply 'get_base_libs'/1 + (_rec48) of + %% Line 1057 + <{'ok',_52,RestLibs}> when 'true' -> + %% Line 1058 + ( case _1 of + ( <( {'release',_53,_54,_rec49,_55,_56} + -| ['compiler_generated'] )> when 'true' -> + let = + [%% Line 1059 + Kernel|%% Line 1059 + [Stdlib|[Sasl|RestLibs]]] + in %% Line 1063 + case _0 of + <{'release',_rec51,_rec52,_rec53,_rec54,_rec55}> when 'true' -> + let <_22> = + {'release',_rec51,TmpVsn,_rec49,TmpLibs,'unpacked'} + in do %% Line 1064 + apply 'new_emulator_make_hybrid_boot'/6 + (_rec45, _rec46, TmpVsn, _2, _3, _4) + do %% Line 1066 + apply 'new_emulator_make_hybrid_config'/5 + (_rec45, _rec46, TmpVsn, _2, _4) + %% Line 1068 + {TmpVsn,_22} + ( <_58> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_57> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 1069 + <{'error',{'missing',Missing}}> when 'true' -> + %% Line 1070 + call 'erlang':'throw' + ({'error',{'missing_base_app',_rec45,Missing}}) + ( <_24> when 'true' -> + primop 'match_fail' + ({'case_clause',_24}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_51> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 1072 + <{'error',{'missing',Missing}}> when 'true' -> + %% Line 1073 + call 'erlang':'throw' + ({'error',{'missing_base_app',_rec46,Missing}}) + ( <_25> when 'true' -> + primop 'match_fail' + ({'case_clause',_25}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_45> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_40> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_35> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'get_base_libs'/1 = + %% Line 1079 + fun (_0) -> + %% Line 1080 + apply 'get_base_libs'/5 + (_0, 'undefined', 'undefined', 'undefined', []) +'get_base_libs'/5 = + %% Line 1081 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + <[Kernel = {'kernel',_11,_12}|Libs],'undefined',Stdlib,Sasl,Rest> when 'true' -> + %% Line 1082 + apply 'get_base_libs'/5 + (Libs, Kernel, Stdlib, Sasl, Rest) + %% Line 1083 + <[Stdlib = {'stdlib',_13,_14}|Libs],Kernel,'undefined',Sasl,Rest> when 'true' -> + %% Line 1084 + apply 'get_base_libs'/5 + (Libs, Kernel, Stdlib, Sasl, Rest) + %% Line 1085 + <[Sasl = {'sasl',_15,_16}|Libs],Kernel,Stdlib,'undefined',Rest> when 'true' -> + %% Line 1086 + apply 'get_base_libs'/5 + (Libs, Kernel, Stdlib, Sasl, Rest) + %% Line 1087 + <[Lib|Libs],Kernel,Stdlib,Sasl,Rest> when 'true' -> + %% Line 1088 + apply 'get_base_libs'/5 + (Libs, Kernel, Stdlib, Sasl, [Lib|Rest]) + %% Line 1089 + <[],'undefined',_X_Stdlib,_X_Sasl,_X_Rest> when 'true' -> + %% Line 1090 + {'error',{'missing','kernel'}} + %% Line 1091 + <[],_X_Kernel,'undefined',_X_Sasl,_X_Rest> when 'true' -> + %% Line 1092 + {'error',{'missing','stdlib'}} + %% Line 1093 + <[],_X_Kernel,_X_Stdlib,'undefined',_X_Rest> when 'true' -> + %% Line 1094 + {'error',{'missing','sasl'}} + %% Line 1095 + <[],Kernel,Stdlib,Sasl,Rest> when 'true' -> + let <_5> = + call %% Line 1096 + 'lists':%% Line 1096 + 'reverse' + (%% Line 1096 + Rest) + in %% Line 1096 + {'ok',{Kernel,Stdlib,Sasl},_5} + ( <_10,_9,_8,_7,_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_10,_9,_8,_7,_6}) + -| [{'function_name',{'get_base_libs',5}}] ) + -| ['compiler_generated'] ) + end +'new_emulator_make_hybrid_boot'/6 = + %% Line 1098 + fun (_0,_1,_2,_3,_4,_5) -> + let = + call %% Line 1099 + 'filename':%% Line 1099 + 'join' + (%% Line 1099 + [_3|[_0|[[115|[116|[97|[114|[116|[46|[98|[111|[111|[116]]]]]]]]]]]]]) + in let = + call %% Line 1100 + 'filename':%% Line 1100 + 'join' + (%% Line 1100 + [_3|[_1|[[115|[116|[97|[114|[116|[46|[98|[111|[111|[116]]]]]]]]]]]]]) + in let = + call %% Line 1101 + 'filename':%% Line 1101 + 'join' + (%% Line 1101 + [_3|[_2|[[115|[116|[97|[114|[116|[46|[98|[111|[111|[116]]]]]]]]]]]]]) + in do %% Line 1102 + apply 'ensure_dir'/2 + (TmpBootFile, _5) + let = + [_1|%% Line 1103 + [_4|[]]] + in %% Line 1104 + case apply 'read_file'/2 + (FromBootFile, _5) of + <{'ok',FromBoot}> when 'true' -> + %% Line 1105 + case apply 'read_file'/2 + (ToBootFile, _5) of + <{'ok',ToBoot}> when 'true' -> + %% Line 1106 + case call 'systools_make':'make_hybrid_boot' + (_2, FromBoot, ToBoot, Args) of + %% Line 1107 + <{'ok',TmpBoot}> when 'true' -> + %% Line 1108 + apply 'write_file'/3 + (TmpBootFile, TmpBoot, _5) + %% Line 1109 + <{'error',Reason}> when 'true' -> + %% Line 1110 + call 'erlang':'throw' + ({'error',{'could_not_create_hybrid_boot',Reason}}) + ( <_12> when 'true' -> + primop 'match_fail' + ({'case_clause',_12}) + -| ['compiler_generated'] ) + end + ( <_11> when 'true' -> + primop 'match_fail' + ({'badmatch',_11}) + -| ['compiler_generated'] ) + end + ( <_10> when 'true' -> + primop 'match_fail' + ({'badmatch',_10}) + -| ['compiler_generated'] ) + end +'new_emulator_make_hybrid_config'/5 = + %% Line 1113 + fun (_0,_1,_2,_3,_4) -> + let = + call %% Line 1114 + 'filename':%% Line 1114 + 'join' + (%% Line 1114 + [_3|[_0|[[115|[121|[115|[46|[99|[111|[110|[102|[105|[103]]]]]]]]]]]]]) + in let = + call %% Line 1115 + 'filename':%% Line 1115 + 'join' + (%% Line 1115 + [_3|[_1|[[115|[121|[115|[46|[99|[111|[110|[102|[105|[103]]]]]]]]]]]]]) + in let = + call %% Line 1116 + 'filename':%% Line 1116 + 'join' + (%% Line 1116 + [_3|[_2|[[115|[121|[115|[46|[99|[111|[110|[102|[105|[103]]]]]]]]]]]]]) + in let <_9> = + case %% Line 1119 + apply 'consult'/2 + (FromFile, _4) of + %% Line 1120 + <{'ok',[FC|[]]}> when 'true' -> + %% Line 1121 + FC + %% Line 1122 + <{'error',Error1}> when 'true' -> + do %% Line 1123 + call 'io':'format' + ([87|[97|[114|[110|[105|[110|[103|[58|[32|[126|[119|[32|[99|[97|[110|[110|[111|[116|[32|[114|[101|[97|[100|[32|[126|[116|[112|[58|[32|[126|[116|[112|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 1124 + ['release_handler'|[FromFile|[Error1|[]]]]) + %% Line 1125 + [] + ( <_8> when 'true' -> + %% Line 1119 + primop 'match_fail' + ({'case_clause',_8}) + -| ['compiler_generated'] ) + end + in let <_17> = + case %% Line 1129 + apply 'consult'/2 + (ToFile, _4) of + %% Line 1130 + <{'ok',[ToConfig|[]]}> when 'true' -> + %% Line 1131 + ( letrec + 'lc$^0'/1 = + fun (_13) -> + case _13 of + <[App|_12]> when 'true' -> + let <_14> = + call 'lists':'keyfind' + (App, 1, ToConfig) + in let <_15> = + apply 'lc$^0'/1 + (_12) + in ( [_14|_15] + -| ['compiler_generated'] ) + <[]> when 'true' -> + [] + ( <_30> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_30}) + -| [{'function_name',{'lc$^0',1}}] ) + -| ['compiler_generated'] ) + end + in apply 'lc$^0'/1 + (['kernel'|['stdlib'|['sasl']]]) + -| ['list_comprehension'] ) + %% Line 1132 + <{'error',Error2}> when 'true' -> + do %% Line 1133 + call 'io':'format' + ([87|[97|[114|[110|[105|[110|[103|[58|[32|[126|[119|[32|[99|[97|[110|[110|[111|[116|[32|[114|[101|[97|[100|[32|[126|[116|[112|[58|[32|[126|[116|[112|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 1134 + ['release_handler'|[ToFile|[Error2|[]]]]) + %% Line 1135 + ['false'|['false'|['false']]] + ( <_16> when 'true' -> + %% Line 1129 + primop 'match_fail' + ({'case_clause',_16}) + -| ['compiler_generated'] ) + end + in %% Line 1128 + case _17 of + <[Kernel|[Stdlib|[Sasl|[]]]]> when 'true' -> + let = + apply %% Line 1138 + 'replace_config'/3 + (%% Line 1138 + 'kernel', _9, %% Line 1138 + Kernel) + in let = + apply %% Line 1139 + 'replace_config'/3 + (%% Line 1139 + 'stdlib', %% Line 1139 + Config1, %% Line 1139 + Stdlib) + in let = + apply %% Line 1140 + 'replace_config'/3 + (%% Line 1140 + 'sasl', %% Line 1140 + Config2, %% Line 1140 + Sasl) + in let <_22> = + call %% Line 1143 + 'epp':%% Line 1143 + 'encoding_to_string' + (%% Line 1143 + 'utf8') + in let = + call %% Line 1142 + 'io_lib':%% Line 1142 + 'format' + (%% Line 1142 + [37|[37|[32|[126|[115|[126|[110|[126|[116|[112|[46|[126|[110]]]]]]]]]]]]], %% Line 1143 + [_22|[Config3|[]]]) + in let <_24> = + call %% Line 1144 + 'unicode':%% Line 1144 + 'characters_to_binary' + (%% Line 1144 + ConfigStr) + in %% Line 1144 + apply 'write_file'/3 + (TmpFile, _24, _4) + ( <_18> when 'true' -> + primop 'match_fail' + ({'badmatch',_18}) + -| ['compiler_generated'] ) + end +'replace_config'/3 = + %% Line 1152 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 1153 + call 'lists':'keydelete' + (App, 1, Config) + %% Line 1154 + when 'true' -> + %% Line 1155 + call 'lists':'keystore' + (App, 1, Config, AppConfig) + end +'new_emulator_rm_tmp_release'/6 = + %% Line 1158 + fun (_0,_1,_2,_3,_4,_5) -> + case <_0,_1,_2,_3,_4,_5> of + when 'true' -> + do %% Line 1160 + case call 'os':'type' + () of + %% Line 1161 + <{'win32','nt'}> when 'true' -> + %% Line 1162 + apply 'rename_tmp_service'/3 + (EVsn, TmpVsn, NewVsn) + %% Line 1163 + <_15> when 'true' -> + 'ok' + end + let <_7> = + call %% Line 1166 + 'filename':%% Line 1166 + 'join' + (%% Line 1166 + RelDir, %% Line 1166 + TmpVsn) + in do %% Line 1166 + apply 'remove_dir'/2 + (_7, Masters) + %% Line 1167 + call 'lists':'keydelete' + (TmpVsn, 3, Releases) + %% Line 1168 + <_16,_17,_18,_19,Releases,_20> when 'true' -> + %% Line 1169 + Releases + end +'rename_tmp_service'/3 = + %% Line 1172 + fun (_0,_1,_2) -> + let <_4> = + call %% Line 1173 + 'erlang':%% Line 1173 + 'node' + () + in let <_5> = + call %% Line 1173 + 'erlang':%% Line 1173 + 'atom_to_list' + (_4) + in let <_6> = + call %% Line 1173 + 'string':%% Line 1173 + 'lexemes' + (_5, %% Line 1173 + [64]) + in let <_7> = + call %% Line 1173 + 'erlang':%% Line 1173 + 'hd' + (_6) + in let <_3> = + [95|_1] + in let = + call %% Line 1173 + 'erlang':%% Line 1173 + '++' + (_7, _3) + in let <_10> = + call %% Line 1174 + 'erlang':%% Line 1174 + 'node' + () + in let <_11> = + call %% Line 1174 + 'erlang':%% Line 1174 + 'atom_to_list' + (_10) + in let <_12> = + call %% Line 1174 + 'string':%% Line 1174 + 'lexemes' + (_11, %% Line 1174 + [64]) + in let <_13> = + call %% Line 1174 + 'erlang':%% Line 1174 + 'hd' + (_12) + in let <_9> = + [95|_2] + in let = + call %% Line 1174 + 'erlang':%% Line 1174 + '++' + (_13, _9) + in do %% Line 1175 + case call 'erlsrv':'get_service' + (_0, ToName) of + %% Line 1176 + <{'error',_X_Error}> when 'true' -> + 'ok' + %% Line 1178 + <_X_Data> when 'true' -> + %% Line 1179 + case call 'erlsrv':'remove_service' + (ToName) of + <{'ok',_20}> when 'true' -> + 'ok' + ( <_15> when 'true' -> + primop 'match_fail' + ({'badmatch',_15}) + -| ['compiler_generated'] ) + end + end + %% Line 1182 + apply 'rename_service'/3 + (_0, FromName, ToName) +'rename_service'/3 = + %% Line 1186 + fun (_0,_1,_2) -> + %% Line 1187 + case call 'erlsrv':'rename_service' + (_0, _1, _2) of + %% Line 1188 + <{'ok',_8}> when 'true' -> + %% Line 1189 + case call 'erlsrv':'get_service' + (_0, _2) of + %% Line 1190 + <_@r0 = {'error',Error1}> when 'true' -> + %% Line 1191 + call 'erlang':'throw' + (_@r0) + %% Line 1192 + <_X_Data2> when 'true' -> + %% Line 1193 + 'ok' + end + %% Line 1195 + when 'true' -> + %% Line 1196 + call 'erlang':'throw' + ({'error',{'service_rename_failed',Error2}}) + end +'do_make_services_permanent'/4 = + %% Line 1205 + fun (_0,_1,_2,_3) -> + let <_5> = + call %% Line 1206 + 'erlang':%% Line 1206 + 'node' + () + in let <_6> = + call %% Line 1206 + 'erlang':%% Line 1206 + 'atom_to_list' + (_5) + in let <_7> = + call %% Line 1206 + 'string':%% Line 1206 + 'lexemes' + (_6, %% Line 1206 + [64]) + in let <_8> = + call %% Line 1206 + 'erlang':%% Line 1206 + 'hd' + (_7) + in let <_4> = + [95|_0] + in let = + call %% Line 1207 + 'erlang':%% Line 1207 + '++' + (_8, _4) + in let <_11> = + call %% Line 1208 + 'erlang':%% Line 1208 + 'node' + () + in let <_12> = + call %% Line 1208 + 'erlang':%% Line 1208 + 'atom_to_list' + (_11) + in let <_13> = + call %% Line 1208 + 'string':%% Line 1208 + 'lexemes' + (_12, %% Line 1208 + [64]) + in let <_14> = + call %% Line 1208 + 'erlang':%% Line 1208 + 'hd' + (_13) + in let <_10> = + [95|_1] + in let = + call %% Line 1209 + 'erlang':%% Line 1209 + '++' + (_14, _10) + in %% Line 1210 + case call 'erlsrv':'get_service' + (_3, Name) of + %% Line 1211 + <{'error',_X_Error}> when 'true' -> + let <_16> = + call %% Line 1214 + 'os':%% Line 1214 + 'getenv' + (%% Line 1214 + [69|[82|[76|[83|[82|[86|[95|[83|[69|[82|[86|[73|[67|[69|[95|[78|[65|[77|[69]]]]]]]]]]]]]]]]]]]) + in %% Line 1214 + case <> of + %% Line 1215 + <> + when call 'erlang':'==' + (_16, + PermName) -> + do %% Line 1216 + apply 'rename_service'/3 + (_3, PermName, Name) + do %% Line 1221 + call 'os':'putenv' + ([69|[82|[76|[83|[82|[86|[95|[83|[69|[82|[86|[73|[67|[69|[95|[78|[65|[77|[69]]]]]]]]]]]]]]]]]]], Name) + %% Line 1225 + call 'heart':'cycle' + () + %% Line 1226 + <> when 'true' -> + %% Line 1227 + call 'erlang':'throw' + ({'error','service_name_missmatch'}) + end + %% Line 1229 + when 'true' -> + let = + call %% Line 1230 + 'erlsrv':%% Line 1230 + 'new_service' + (%% Line 1230 + Name, %% Line 1230 + Data, %% Line 1230 + []) + in %% Line 1231 + case call 'erlsrv':'store_service' + (_3, UpdData) of + %% Line 1232 + <'ok'> when 'true' -> + %% Line 1233 + case call 'erlsrv':'disable_service' + (_2, PermName) of + <{'ok',_29}> when 'true' -> + %% Line 1234 + case call 'erlsrv':'enable_service' + (_3, Name) of + <{'ok',_30}> when 'true' -> + %% Line 1235 + case call 'erlsrv':'remove_service' + (PermName) of + <{'ok',_31}> when 'true' -> + do %% Line 1237 + call 'os':'putenv' + ([69|[82|[76|[83|[82|[86|[95|[83|[69|[82|[86|[73|[67|[69|[95|[78|[65|[77|[69]]]]]]]]]]]]]]]]]]], Name) + let <_32> = + call %% Line 1238 + 'heart':%% Line 1238 + 'cycle' + () + in %% Line 1238 + case _32 of + <'ok'> when 'true' -> + ( _32 + -| ['compiler_generated'] ) + ( <_22> when 'true' -> + primop 'match_fail' + ({'badmatch',_22}) + -| ['compiler_generated'] ) + end + ( <_21> when 'true' -> + primop 'match_fail' + ({'badmatch',_21}) + -| ['compiler_generated'] ) + end + ( <_20> when 'true' -> + primop 'match_fail' + ({'badmatch',_20}) + -| ['compiler_generated'] ) + end + ( <_19> when 'true' -> + primop 'match_fail' + ({'badmatch',_19}) + -| ['compiler_generated'] ) + end + %% Line 1239 + when 'true' -> + %% Line 1240 + call 'erlang':'throw' + (Error4) + end + end +'do_make_permanent'/2 = + %% Line 1244 + fun (_0,_1) -> + case <_0,_1> of + <{'state',%% Line 1245 + Unpurged,_30,%% Line 1245 + RelDir,Releases,_31,_32,%% Line 1246 + Masters,_33,%% Line 1247 + Static,_34},%% Line 1248 + Vsn> when 'true' -> + %% Line 1249 + case call 'lists':'keysearch' + (Vsn, 3, Releases) of + %% Line 1250 + <{'value',{'release',_35,_36,EVsn,_37,Status}}> + when %% Line 1251 + try + let <_2> = + call 'erlang':'=/=' + (Status, 'unpacked') + in let <_3> = + call 'erlang':'=/=' + (Status, 'old') + in let <_4> = + call 'erlang':'=/=' + (Status, 'permanent') + in let <_5> = + call 'erlang':'and' + (_3, _4) + in call 'erlang':'and' + (_2, _5) + of -> + Try + catch -> + 'false' -> + let = + call %% Line 1252 + 'filename':%% Line 1252 + 'join' + (%% Line 1252 + [RelDir|[Vsn|[]]]) + in let <_8> = + catch + let <_7> = + call %% Line 1254 + 'filename':%% Line 1254 + 'join' + (%% Line 1254 + Dir, %% Line 1254 + [115|[121|[115|[46|[99|[111|[110|[102|[105|[103]]]]]]]]]]) + in %% Line 1254 + apply 'check_file'/3 + (_7, %% Line 1255 + 'regular', %% Line 1255 + Masters) + in let <_10> = + case _8 of + %% Line 1256 + <'ok'> when 'true' -> + call 'filename':'join' + (Dir, [115|[121|[115]]]) + %% Line 1257 + <_38> when 'true' -> + 'false' + end + in let = + call %% Line 1259 + 'filename':%% Line 1259 + 'join' + (%% Line 1259 + Dir, %% Line 1259 + [115|[116|[97|[114|[116|[46|[98|[111|[111|[116]]]]]]]]]]) + in do %% Line 1260 + apply 'check_file'/3 + (Boot, 'regular', Masters) + do %% Line 1261 + apply 'set_permanent_files'/5 + (RelDir, EVsn, Vsn, Masters, Static) + let = + apply %% Line 1262 + 'set_status'/3 + (%% Line 1262 + Vsn, %% Line 1262 + 'permanent', %% Line 1262 + Releases) + in do %% Line 1263 + apply 'write_releases'/3 + (RelDir, NewReleases, Masters) + do %% Line 1264 + case call 'os':'type' + () of + %% Line 1265 + <{'win32','nt'}> when 'true' -> + %% Line 1266 + case %% Line 1267 + call 'lists':'keysearch' + ('permanent', 6, %% Line 1268 + Releases) of + <{'value',PermanentRelease}> when 'true' -> + %% Line 1269 + ( case PermanentRelease of + ( <( {'release',_39,_rec56,_40,_41,_42} + -| ['compiler_generated'] )> when 'true' -> + %% Line 1270 + ( case PermanentRelease of + ( <( {'release',_44,_45,_rec57,_46,_47} + -| ['compiler_generated'] )> when 'true' -> + let <_21> = + catch + %% Line 1271 + apply 'do_make_services_permanent'/4 + (_rec56, %% Line 1272 + Vsn, _rec57, %% Line 1274 + EVsn) + in %% Line 1271 + case _21 of + %% Line 1275 + <{'error',Reason}> when 'true' -> + %% Line 1276 + call 'erlang':'throw' + ({'error',{'service_update_failed',Reason}}) + %% Line 1277 + <_49> when 'true' -> + 'ok' + end + -| ['compiler_generated'] ) + ( <_48> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_43> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_14> when 'true' -> + primop 'match_fail' + ({'badmatch',_14}) + -| ['compiler_generated'] ) + end + %% Line 1280 + <_50> when 'true' -> + 'ok' + end + let <_24> = + call %% Line 1283 + 'filename':%% Line 1283 + 'join' + (%% Line 1283 + Dir, %% Line 1283 + [115|[116|[97|[114|[116]]]]]) + in %% Line 1283 + case call 'init':'make_permanent' + (_24, _10) of + <'ok'> when 'true' -> + let <_26> = + apply %% Line 1284 + 'brutal_purge'/1 + (%% Line 1284 + Unpurged) + in %% Line 1284 + {'ok',NewReleases,_26} + ( <_25> when 'true' -> + primop 'match_fail' + ({'badmatch',_25}) + -| ['compiler_generated'] ) + end + %% Line 1285 + <{'value',{'release',_51,_52,_53,_54,'permanent'}}> when 'true' -> + %% Line 1286 + {'ok',Releases,Unpurged} + %% Line 1287 + <{'value',{'release',_55,_56,_57,_58,Status}}> when 'true' -> + %% Line 1288 + {'error',{'bad_status',Status}} + %% Line 1289 + <'false'> when 'true' -> + %% Line 1290 + {'error',{'no_such_release',Vsn}} + ( <_27> when 'true' -> + primop 'match_fail' + ({'case_clause',_27}) + -| ['compiler_generated'] ) + end + ( <_29,_28> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_29,_28}) + -| [{'function_name',{'do_make_permanent',2}}] ) + -| ['compiler_generated'] ) + end +'do_back_service'/4 = + %% Line 1294 + fun (_0,_1,_2,_3) -> + let <_4> = + call %% Line 1295 + 'erlang':%% Line 1295 + 'node' + () + in let <_5> = + call %% Line 1295 + 'erlang':%% Line 1295 + 'atom_to_list' + (_4) + in let <_6> = + call %% Line 1295 + 'string':%% Line 1295 + 'lexemes' + (_5, %% Line 1295 + [64]) + in let = + call %% Line 1295 + 'erlang':%% Line 1295 + 'hd' + (_6) + in let <_8> = + [95|_0] + in let = + call %% Line 1296 + 'erlang':%% Line 1296 + '++' + (%% Line 1296 + NN, _8) + in let <_10> = + [95|_1] + in let = + call %% Line 1297 + 'erlang':%% Line 1297 + '++' + (%% Line 1297 + NN, _10) + in let <_13> = + case %% Line 1298 + call 'erlsrv':'get_service' + (_3, CurrentName) of + %% Line 1299 + <_@r0 = {'error',Error}> when 'true' -> + %% Line 1300 + call 'erlang':'throw' + (_@r0) + %% Line 1301 + when 'true' -> + %% Line 1302 + call 'erlsrv':'new_service' + (OldName, Data, []) + end + in %% Line 1304 + case ( call ( 'erlsrv' + -| ['result_not_wanted'] ):( 'store_service' + -| ['result_not_wanted'] ) + (_2, _13) + -| ['result_not_wanted'] ) of + %% Line 1305 + <'ok'> when 'true' -> + %% Line 1306 + case ( call ( 'erlsrv' + -| ['result_not_wanted'] ):( 'disable_service' + -| ['result_not_wanted'] ) + (_3, CurrentName) + -| ['result_not_wanted'] ) of + <( {'ok',_35} + -| ['result_not_wanted'] )> when 'true' -> + %% Line 1307 + case ( call ( 'erlsrv' + -| ['result_not_wanted'] ):( 'enable_service' + -| ['result_not_wanted'] ) + (_2, OldName) + -| ['result_not_wanted'] ) of + <( {'ok',_37} + -| ['result_not_wanted'] )> when 'true' -> + let <_20> = + call %% Line 1311 + 'erlsrv':%% Line 1311 + 'erlsrv' + (_2) + in let = + call %% Line 1311 + 'filename':%% Line 1311 + 'nativename' + (_20) + in let <_22> = + call %% Line 1312 + 'erlsrv':%% Line 1312 + 'erlsrv' + (_3) + in let = + call %% Line 1312 + 'filename':%% Line 1312 + 'nativename' + (_22) + in let <_24> = + call %% Line 1314 + 'erlang':%% Line 1314 + '++' + (%% Line 1314 + [32|[115|[116|[97|[114|[116|[32]]]]]]], %% Line 1314 + OldName) + in let <_25> = + call %% Line 1314 + 'erlang':%% Line 1314 + '++' + (%% Line 1314 + OldErlSrv, _24) + in let <_26> = + [32|%% Line 1314 + [38|[32|_25]]] + in let <_27> = + call %% Line 1313 + 'erlang':%% Line 1313 + '++' + (%% Line 1313 + CurrentName, _26) + in let <_28> = + call %% Line 1313 + 'erlang':%% Line 1313 + '++' + (%% Line 1313 + [32|[114|[101|[109|[111|[118|[101|[32]]]]]]]], _27) + in let <_29> = + call %% Line 1313 + 'erlang':%% Line 1313 + '++' + (%% Line 1313 + CurrentErlSrv, _28) + in %% Line 1313 + case call 'heart':'set_cmd' + (_29) of + %% Line 1315 + <'ok'> when 'true' -> + %% Line 1316 + 'ok' + %% Line 1317 + when 'true' -> + %% Line 1318 + call 'erlang':'throw' + ({'error',{'heart:set_cmd() error',Error3}}) + end + ( <_16> when 'true' -> + primop 'match_fail' + ({'badmatch',_16}) + -| ['compiler_generated'] ) + end + ( <_15> when 'true' -> + primop 'match_fail' + ({'badmatch',_15}) + -| ['compiler_generated'] ) + end + %% Line 1308 + when 'true' -> + %% Line 1309 + ( call ( 'erlang' + -| ['result_not_wanted'] ):( 'throw' + -| ['result_not_wanted'] ) + (Error2) + -| ['result_not_wanted'] ) + end +'do_reboot_old_release'/2 = + %% Line 1321 + fun (_0,_1) -> + case <_0,_1> of + <{'state',_15,_16,%% Line 1322 + RelDir,Releases,_17,_18,%% Line 1322 + Masters,_19,%% Line 1323 + Static,_20},%% Line 1324 + Vsn> when 'true' -> + %% Line 1325 + case call 'lists':'keysearch' + (Vsn, 3, Releases) of + %% Line 1326 + <{'value',{'release',_21,_22,EVsn,_23,'old'}}> when 'true' -> + let <_4> = + case %% Line 1327 + call 'os':'type' + () of + %% Line 1328 + <{'win32','nt'}> when 'true' -> + %% Line 1330 + case call 'lists':'keysearch' + ('permanent', %% Line 1331 + 6, %% Line 1332 + Releases) of + %% Line 1333 + <'false'> when 'true' -> + %% Line 1334 + call 'lists':'keysearch' + ('current', %% Line 1335 + 6, %% Line 1336 + Releases) + %% Line 1337 + <{'value',CR}> when 'true' -> + %% Line 1338 + CR + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end + %% Line 1340 + <_24> when 'true' -> + %% Line 1341 + 'false' + end + in do %% Line 1343 + apply 'set_permanent_files'/5 + (RelDir, EVsn, Vsn, Masters, Static) + let = + apply %% Line 1344 + 'set_status'/3 + (%% Line 1344 + Vsn, %% Line 1344 + 'permanent', %% Line 1344 + Releases) + in do %% Line 1345 + apply 'write_releases'/3 + (RelDir, NewReleases, Masters) + do %% Line 1346 + case call 'os':'type' + () of + %% Line 1347 + <{'win32','nt'}> when 'true' -> + %% Line 1350 + ( case _4 of + ( <( {'release',_25,_rec58,_26,_27,_28} + -| ['compiler_generated'] )> when 'true' -> + %% Line 1351 + ( case _4 of + ( <( {'release',_30,_31,_rec59,_32,_33} + -| ['compiler_generated'] )> when 'true' -> + apply 'do_back_service'/4 + (Vsn, _rec58, EVsn, _rec59) + -| ['compiler_generated'] ) + ( <_34> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_29> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 1352 + <_35> when 'true' -> + 'ok' + end + %% Line 1355 + 'ok' + %% Line 1356 + <{'value',{'release',_36,_37,_38,_39,Status}}> when 'true' -> + %% Line 1357 + {'error',{'bad_status',Status}} + %% Line 1358 + <'false'> when 'true' -> + %% Line 1359 + {'error',{'no_such_release',Vsn}} + ( <_12> when 'true' -> + primop 'match_fail' + ({'case_clause',_12}) + -| ['compiler_generated'] ) + end + ( <_14,_13> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_14,_13}) + -| [{'function_name',{'do_reboot_old_release',2}}] ) + -| ['compiler_generated'] ) + end +'set_permanent_files'/5 = + %% Line 1367 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + when 'true' -> + let <_7> = + call %% Line 1368 + 'filename':%% Line 1368 + 'join' + (%% Line 1368 + [RelDir|[[115|[116|[97|[114|[116|[95|[101|[114|[108|[46|[100|[97|[116|[97]]]]]]]]]]]]]]]]) + in let <_5> = + [32|%% Line 1369 + Vsn] + in let <_6> = + call %% Line 1369 + 'erlang':%% Line 1369 + '++' + (%% Line 1369 + EVsn, _5) + in %% Line 1368 + apply 'write_start'/3 + (_7, _6, %% Line 1370 + 'false') + %% Line 1371 + when 'true' -> + let <_10> = + call %% Line 1372 + 'filename':%% Line 1372 + 'join' + (%% Line 1372 + [RelDir|[[115|[116|[97|[114|[116|[95|[101|[114|[108|[46|[100|[97|[116|[97]]]]]]]]]]]]]]]]) + in let <_8> = + [32|%% Line 1373 + Vsn] + in let <_9> = + call %% Line 1373 + 'erlang':%% Line 1373 + '++' + (%% Line 1373 + EVsn, _8) + in %% Line 1372 + apply 'write_start'/3 + (_10, _9, %% Line 1374 + Masters) + %% Line 1375 + when 'true' -> + let = + call %% Line 1376 + 'filename':%% Line 1376 + 'join' + (%% Line 1376 + [RelDir|[Vsn|[]]]) + in %% Line 1377 + apply 'set_static_files'/3 + (VsnDir, RelDir, Masters) + end +'do_remove_service'/1 = + %% Line 1380 + fun (_0) -> + let <_2> = + call %% Line 1384 + 'erlang':%% Line 1384 + 'node' + () + in let <_3> = + call %% Line 1384 + 'erlang':%% Line 1384 + 'atom_to_list' + (_2) + in let <_4> = + call %% Line 1384 + 'string':%% Line 1384 + 'lexemes' + (_3, %% Line 1384 + [64]) + in let <_5> = + call %% Line 1384 + 'erlang':%% Line 1384 + 'hd' + (_4) + in let <_1> = + [95|_0] + in let = + call %% Line 1385 + 'erlang':%% Line 1385 + '++' + (_5, _1) + in %% Line 1386 + case call 'erlsrv':'get_service' + (ServiceName) of + %% Line 1387 + <{'error',_X_Error}> when 'true' -> + %% Line 1388 + 'ok' + %% Line 1389 + <_X_Data> when 'true' -> + %% Line 1390 + case call 'erlsrv':'remove_service' + (ServiceName) of + <{'ok',_10}> when 'true' -> + %% Line 1391 + 'ok' + ( <_7> when 'true' -> + primop 'match_fail' + ({'badmatch',_7}) + -| ['compiler_generated'] ) + end + end +'do_remove_release'/4 = + %% Line 1394 + fun (_0,_1,_2,_3) -> + %% Line 1396 + case call 'lists':'keysearch' + (_2, 3, _3) of + %% Line 1397 + <{'value',{'release',_24,_25,_26,_27,'permanent'}}> when 'true' -> + %% Line 1398 + {'error',{'permanent',_2}} + %% Line 1399 + <{'value',{'release',_28,_29,EVsn,RemoveLibs,_30}}> + when call 'erlang':'=:=' + (_29, + _2) -> + do %% Line 1400 + case call 'os':'type' + () of + %% Line 1401 + <{'win32','nt'}> when 'true' -> + %% Line 1402 + apply 'do_remove_service'/1 + (_2) + %% Line 1403 + <_31> when 'true' -> + 'ok' + end + let = + call %% Line 1407 + 'lists':%% Line 1407 + 'keydelete' + (_2, %% Line 1407 + 3, _3) + in let <_10> = + fun (_7,_6) -> + %% Line 1409 + case <_7,_6> of + <{'release',_32,_33,_34,Libs,_35},Remove> when 'true' -> + %% Line 1410 + apply 'diff_dir'/2 + (Remove, Libs) + ( <_9,_8> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_9,_8}) + -| [{'function_name',{'-do_remove_release/4-fun-0-',2}}] ) + -| ['compiler_generated'] ) + end + in let = + call %% Line 1409 + 'lists':%% Line 1409 + 'foldl' + (_10, %% Line 1411 + RemoveLibs, %% Line 1411 + NewReleases) + in let <_14> = + fun (_12) -> + %% Line 1412 + case _12 of + <{_X_Lib,_X_LVsn,LDir}> when 'true' -> + %% Line 1413 + apply 'remove_file'/1 + (LDir) + ( <_13> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_13}) + -| [{'function_name',{'-do_remove_release/4-fun-1-',1}}] ) + -| ['compiler_generated'] ) + end + in do %% Line 1412 + call 'lists':'foreach' + (_14, %% Line 1414 + RemoveThese) + let <_15> = + call %% Line 1415 + 'filename':%% Line 1415 + 'join' + (%% Line 1415 + [_1|[_2|[]]]) + in do %% Line 1415 + apply 'remove_file'/1 + (_15) + do %% Line 1416 + case call 'lists':'keysearch' + (EVsn, 4, NewReleases) of + %% Line 1417 + <{'value',_36}> when 'true' -> + 'ok' + %% Line 1418 + <'false'> when 'true' -> + let <_16> = + call %% Line 1419 + 'erlang':%% Line 1419 + '++' + (%% Line 1419 + [101|[114|[116|[115|[45]]]]], %% Line 1419 + EVsn) + in let <_17> = + call %% Line 1419 + 'filename':%% Line 1419 + 'join' + (_0, _16) + in %% Line 1419 + apply 'remove_file'/1 + (_17) + ( <_18> when 'true' -> + primop 'match_fail' + ({'case_clause',_18}) + -| ['compiler_generated'] ) + end + do %% Line 1421 + apply 'write_releases'/3 + (_1, NewReleases, 'false') + %% Line 1422 + {'ok',NewReleases} + %% Line 1423 + <'false'> when 'true' -> + %% Line 1424 + {'error',{'no_such_release',_2}} + ( <_19> when 'true' -> + primop 'match_fail' + ({'case_clause',_19}) + -| ['compiler_generated'] ) + end +'do_set_unpacked'/6 = + %% Line 1427 + fun (_0,_1,_2,_3,_4,_5) -> + let = + apply %% Line 1428 + 'check_rel'/4 + (_0, _2, _3, _5) + in %% Line 1429 + case Release of + <{'release',_20,Vsn,_21,_22,_23}> when 'true' -> + do %% Line 1430 + case call 'lists':'keysearch' + (Vsn, 3, _4) of + %% Line 1431 + <{'value',_24}> when 'true' -> + call 'erlang':'throw' + ({'error',{'existing_release',Vsn}}) + %% Line 1432 + <'false'> when 'true' -> + 'ok' + ( <_8> when 'true' -> + primop 'match_fail' + ({'case_clause',_8}) + -| ['compiler_generated'] ) + end + %% Line 1434 + case Release of + <{'release',_25,_26,_27,_28,_29}> when 'true' -> + let <_11> = + call 'erlang':'setelement' + (6, Release, 'unpacked') + in let = + [_11|_4] + in let = + call %% Line 1435 + 'filename':%% Line 1435 + 'join' + (%% Line 1435 + [_1|[Vsn|[]]]) + in do %% Line 1436 + apply 'make_dir'/2 + (VsnDir, _5) + do %% Line 1437 + apply 'write_releases'/3 + (_1, NewReleases, _5) + %% Line 1438 + {'ok',NewReleases,Vsn} + ( <_30> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + ( <_7> when 'true' -> + primop 'match_fail' + ({'badmatch',_7}) + -| ['compiler_generated'] ) + end +'do_set_removed'/4 = + %% Line 1440 + fun (_0,_1,_2,_3) -> + %% Line 1441 + case call 'lists':'keysearch' + (_1, 3, _2) of + %% Line 1442 + <{'value',{'release',_10,_11,_12,_13,'permanent'}}> when 'true' -> + %% Line 1443 + {'error',{'permanent',_1}} + %% Line 1444 + <{'value',_14}> when 'true' -> + let = + call %% Line 1445 + 'lists':%% Line 1445 + 'keydelete' + (_1, %% Line 1445 + 3, _2) + in do %% Line 1446 + apply 'write_releases'/3 + (_0, NewReleases, _3) + %% Line 1447 + {'ok',NewReleases} + %% Line 1448 + <'false'> when 'true' -> + %% Line 1449 + {'error',{'no_such_release',_1}} + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end +'get_rh_script'/4 = + %% Line 1471 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <{'release',_9,[95|[95|[110|[101|[119|[95|[101|[109|[117|[108|[97|[116|[111|[114|[95|[95|CurrentVsn]]]]]]]]]]]]]]]],_10,_11,_12},%% Line 1472 + {'release',_13,ToVsn,_14,_15,_16},%% Line 1473 + RelDir,%% Line 1474 + Masters> when 'true' -> + %% Line 1475 + case %% Line 1476 + apply 'do_get_rh_script'/4 + (CurrentVsn, ToVsn, RelDir, Masters) of + <{'ok',{Vsn,Descr,['restart_new_emulator'|Script]}}> when 'true' -> + %% Line 1477 + {'ok',{Vsn,Descr,Script}} + ( <_4> when 'true' -> + primop 'match_fail' + ({'badmatch',_4}) + -| ['compiler_generated'] ) + end + %% Line 1478 + <{'release',_17,CurrentVsn,_18,_19,_20},%% Line 1479 + {'release',_21,ToVsn,_22,_23,_24},%% Line 1480 + RelDir,%% Line 1481 + Masters> when 'true' -> + %% Line 1482 + apply 'do_get_rh_script'/4 + (CurrentVsn, ToVsn, RelDir, Masters) + ( <_8,_7,_6,_5> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_8,_7,_6,_5}) + -| [{'function_name',{'get_rh_script',4}}] ) + -| ['compiler_generated'] ) + end +'do_get_rh_script'/4 = + %% Line 1484 + fun (_0,_1,_2,_3) -> + let = + call %% Line 1485 + 'filename':%% Line 1485 + 'join' + (%% Line 1485 + [_2|[_1|[[114|[101|[108|[117|[112]]]]]]]]) + in %% Line 1486 + case apply 'try_upgrade'/4 + (_1, _0, Relup, _3) of + %% Line 1487 + <_@r0 = {'ok',RhScript}> when 'true' -> + %% Line 1488 + _@r0 + %% Line 1489 + <_12> when 'true' -> + let = + call %% Line 1490 + 'filename':%% Line 1490 + 'join' + (%% Line 1490 + [_2|[_0|[[114|[101|[108|[117|[112]]]]]]]]) + in %% Line 1491 + case apply 'try_downgrade'/4 + (_1, _0, Relup2, _3) of + %% Line 1492 + <_@r1 = {'ok',RhScript}> when 'true' -> + %% Line 1493 + _@r1 + %% Line 1494 + <_13> when 'true' -> + %% Line 1495 + call 'erlang':'throw' + ({'error',{'no_matching_relup',_1,_0}}) + end + end +'try_upgrade'/4 = + %% Line 1499 + fun (_0,_1,_2,_3) -> + %% Line 1500 + case apply 'consult'/2 + (_2, _3) of + %% Line 1501 + <{'ok',[{_10,ListOfRhScripts,_11}|[]]}> + when call 'erlang':'=:=' + (_10, + _0) -> + %% Line 1502 + case call 'lists':'keysearch' + (_1, 1, ListOfRhScripts) of + %% Line 1503 + <{'value',RhScript}> when 'true' -> + %% Line 1504 + {'ok',RhScript} + %% Line 1505 + <_12> when 'true' -> + %% Line 1506 + 'error' + end + %% Line 1508 + <{'ok',_13}> when 'true' -> + %% Line 1509 + call 'erlang':'throw' + ({'error',{'bad_relup_file',_2}}) + %% Line 1510 + <{'error',Reason}> + when call 'erlang':'is_tuple' + (Reason) -> + %% Line 1511 + call 'erlang':'throw' + ({'error',{'bad_relup_file',_2}}) + %% Line 1512 + <{'error','enoent'}> when 'true' -> + %% Line 1513 + 'error' + %% Line 1514 + <{'error',FileError}> when 'true' -> + %% Line 1515 + call 'erlang':'throw' + ({'error',{FileError,_2}}) + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end +'try_downgrade'/4 = + %% Line 1518 + fun (_0,_1,_2,_3) -> + %% Line 1519 + case apply 'consult'/2 + (_2, _3) of + %% Line 1520 + <{'ok',[{_10,_11,ListOfRhScripts}|[]]}> + when call 'erlang':'=:=' + (_10, + _1) -> + %% Line 1521 + case call 'lists':'keysearch' + (_0, 1, ListOfRhScripts) of + %% Line 1522 + <{'value',RhScript}> when 'true' -> + %% Line 1523 + {'ok',RhScript} + %% Line 1524 + <_12> when 'true' -> + %% Line 1525 + 'error' + end + %% Line 1527 + <{'ok',_13}> when 'true' -> + %% Line 1528 + call 'erlang':'throw' + ({'error',{'bad_relup_file',_2}}) + %% Line 1529 + <{'error',Reason}> + when call 'erlang':'is_tuple' + (Reason) -> + %% Line 1530 + call 'erlang':'throw' + ({'error',{'bad_relup_file',_2}}) + %% Line 1531 + <{'error',FileError}> when 'true' -> + %% Line 1532 + call 'erlang':'throw' + ({'error',{FileError,_2}}) + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end +'set_status'/3 = + %% Line 1537 + fun (_0,_1,_2) -> + let <_32> = + fun (_30) -> + %% Line 1538 + case _30 of + + when ( try + let <_7> = + call 'erlang':'element' + (3, Release) + in let <_8> = + call 'erlang':'==' + (_7, _0) + in let <_10> = + call %% Line 1539 + 'erlang':%% Line 1539 + 'element' + (%% Line 1539 + 6, %% Line 1539 + Release) + in let <_11> = + call %% Line 1539 + 'erlang':%% Line 1539 + '=:=' + (_10, %% Line 1539 + 'permanent') + in ( call ( 'erlang' + -| ['compiler_generated'] ):( 'and' + -| ['compiler_generated'] ) + (_8, _11) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + %% Line 1543 + 'true' + %% Line 1544 + + when ( try + let <_16> = + call 'erlang':'element' + (3, Release) + in call 'erlang':'==' + (_16, _0) + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + %% Line 1545 + case Release of + <{'release',_46,_47,_48,_49,_50}> when 'true' -> + let <_20> = + call 'erlang':'setelement' + (6, Release, _1) + in {'true',_20} + ( <_51> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 1546 + + when ( try + let <_25> = + call 'erlang':'element' + (6, Release) + in call 'erlang':'==' + (_25, _1) + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + %% Line 1547 + case Release of + <{'release',_57,_58,_59,_60,_61}> when 'true' -> + let <_29> = + call 'erlang':'setelement' + (6, Release, 'old') + in {'true',_29} + ( <_62> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 1548 + <_63> when 'true' -> + %% Line 1549 + 'true' + end + in %% Line 1538 + call 'lists':'zf' + (_32, _2) +'get_latest_release'/1 = + %% Line 1552 + fun (_0) -> + %% Line 1553 + case call 'lists':'keysearch' + ('current', 6, _0) of + %% Line 1554 + <{'value',Release}> when 'true' -> + %% Line 1555 + Release + %% Line 1556 + <'false'> when 'true' -> + %% Line 1557 + case %% Line 1558 + call 'lists':'keysearch' + ('permanent', 6, _0) of + <{'value',Release}> when 'true' -> + %% Line 1559 + Release + ( <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + -| ['compiler_generated'] ) + end + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end +'diff_dir'/2 = + %% Line 1563 + fun (_0,_1) -> + case <_0,_1> of + <[H|T],L> when 'true' -> + %% Line 1564 + case apply 'memlib'/2 + (H, L) of + %% Line 1565 + <'true'> when 'true' -> + apply 'diff_dir'/2 + (T, L) + %% Line 1566 + <'false'> when 'true' -> + let <_2> = + apply 'diff_dir'/2 + (T, L) + in [H|_2] + ( <_3> when 'true' -> + primop 'match_fail' + ({'case_clause',_3}) + -| ['compiler_generated'] ) + end + %% Line 1568 + <[],_6> when 'true' -> + [] + ( <_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4}) + -| [{'function_name',{'diff_dir',2}}] ) + -| ['compiler_generated'] ) + end +'memlib'/2 = + %% Line 1570 + fun (_0,_1) -> + case <_0,_1> of + <{Lib,Vsn,_X_Dir},[{_4,_5,_X_Dir2}|_X_T]> + when let <_6> = + call 'erlang':'=:=' + (_4, Lib) + in let <_7> = + call 'erlang':'=:=' + (_5, Vsn) + in call 'erlang':'and' + (_6, _7) -> + 'true' + %% Line 1571 + when 'true' -> + apply 'memlib'/2 + (Lib, T) + %% Line 1572 + <_X_Lib,[]> when 'true' -> + 'false' + ( <_3,_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3,_2}) + -| [{'function_name',{'memlib',2}}] ) + -| ['compiler_generated'] ) + end +'remove_file'/1 = + %% Line 1575 + fun (_0) -> + %% Line 1576 + case call 'file':'read_link_info' + (_0) of + %% Line 1577 + <{'ok',Info = {'file_info',_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27,_28}}> + when ( try + let <_5> = + call 'erlang':'element' + (3, Info) + in call 'erlang':'=:=' + (_5, 'directory') + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + %% Line 1578 + case call 'file':'list_dir' + (_0) of + %% Line 1579 + <{'ok',Files}> when 'true' -> + let <_10> = + fun (_8) -> + let <_7> = + call %% Line 1581 + 'filename':%% Line 1581 + 'join' + (_0, %% Line 1580 + _8) + in %% Line 1581 + apply 'remove_file'/1 + (_7) + in do %% Line 1580 + call 'lists':'foreach' + (_10, %% Line 1582 + Files) + %% Line 1583 + case call 'file':'del_dir' + (_0) of + %% Line 1584 + <'ok'> when 'true' -> + 'ok' + %% Line 1585 + <_@r0 = {'error',Reason}> when 'true' -> + call 'erlang':'throw' + (_@r0) + ( <_11> when 'true' -> + primop 'match_fail' + ({'case_clause',_11}) + -| ['compiler_generated'] ) + end + %% Line 1587 + <_@r1 = {'error',Reason}> when 'true' -> + %% Line 1588 + call 'erlang':'throw' + (_@r1) + ( <_12> when 'true' -> + primop 'match_fail' + ({'case_clause',_12}) + -| ['compiler_generated'] ) + end + %% Line 1590 + <{'ok',_X_Info}> when 'true' -> + %% Line 1591 + case call 'file':'delete' + (_0) of + %% Line 1592 + <'ok'> when 'true' -> + 'ok' + %% Line 1593 + <_@r2 = {'error',Reason}> when 'true' -> + call 'erlang':'throw' + (_@r2) + ( <_13> when 'true' -> + primop 'match_fail' + ({'case_clause',_13}) + -| ['compiler_generated'] ) + end + %% Line 1595 + <{'error',_X_Reason}> when 'true' -> + %% Line 1596 + call 'erlang':'throw' + ({'error',{'no_such_file',_0}}) + ( <_14> when 'true' -> + primop 'match_fail' + ({'case_clause',_14}) + -| ['compiler_generated'] ) + end +'do_write_file'/2 = + %% Line 1600 + fun (_0,_1) -> + %% Line 1601 + apply 'do_write_file'/3 + (_0, _1, []) +'do_write_file'/3 = + %% Line 1602 + fun (_0,_1,_2) -> + %% Line 1603 + case call 'file':'open' + (_0, ['write'|_2]) of + %% Line 1604 + <{'ok',Fd}> when 'true' -> + do %% Line 1605 + call 'io':'put_chars' + (Fd, _1) + let <_8> = + call %% Line 1606 + 'file':%% Line 1606 + 'close' + (%% Line 1606 + Fd) + in %% Line 1606 + case _8 of + <'ok'> when 'true' -> + ( _8 + -| ['compiler_generated'] ) + ( <_3> when 'true' -> + primop 'match_fail' + ({'badmatch',_3}) + -| ['compiler_generated'] ) + end + %% Line 1607 + <{'error',Reason}> when 'true' -> + %% Line 1608 + {'error',{Reason,_0}} + ( <_4> when 'true' -> + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end +'change_appl_data'/3 = + %% Line 1615 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + let = + call %% Line 1616 + 'filename':%% Line 1616 + 'join' + (%% Line 1616 + [RelDir|[Vsn|[]]]) + in let = + call %% Line 1617 + 'filename':%% Line 1617 + 'join' + (%% Line 1617 + Dir, %% Line 1617 + [115|[116|[97|[114|[116|[46|[98|[111|[111|[116]]]]]]]]]]) + in %% Line 1618 + case apply 'read_file'/2 + (BootFile, Masters) of + %% Line 1619 + <{'ok',Bin}> when 'true' -> + let <_5> = + call %% Line 1620 + 'filename':%% Line 1620 + 'join' + (%% Line 1620 + Dir, %% Line 1620 + [115|[121|[115|[46|[99|[111|[110|[102|[105|[103]]]]]]]]]]) + in let <_7> = + case %% Line 1620 + apply 'consult'/2 + (_5, Masters) of + %% Line 1621 + <{'ok',[Conf|[]]}> when 'true' -> + Conf + %% Line 1622 + <_20> when 'true' -> + [] + end + in let <_9> = + call %% Line 1624 + 'erlang':%% Line 1624 + 'binary_to_term' + (%% Line 1624 + Bin) + in let = + apply %% Line 1624 + 'get_appls'/1 + (_9) + in %% Line 1625 + case call 'application_controller':'change_application_data' + (Appls, _7) of + %% Line 1626 + <'ok'> when 'true' -> + Appls + %% Line 1627 + <{'error',Reason}> when 'true' -> + call 'erlang':'exit' + ({'change_appl_data',Reason}) + ( <_11> when 'true' -> + primop 'match_fail' + ({'case_clause',_11}) + -| ['compiler_generated'] ) + end + %% Line 1629 + <{'error',_X_Reason}> when 'true' -> + %% Line 1630 + call 'erlang':'throw' + ({'error',{'no_such_file',BootFile}}) + ( <_12> when 'true' -> + primop 'match_fail' + ({'case_clause',_12}) + -| ['compiler_generated'] ) + end + ( <_15,_14,_13> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_15,_14,_13}) + -| [{'function_name',{'change_appl_data',3}}] ) + -| ['compiler_generated'] ) + end +'get_appls'/1 = + %% Line 1637 + fun (_0) -> + case _0 of + <{'script',_2,Script}> when 'true' -> + apply 'get_appls'/2 + (Script, []) + ( <_1> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_1}) + -| [{'function_name',{'get_appls',1}}] ) + -| ['compiler_generated'] ) + end +'get_appls'/2 = + %% Line 1640 + fun (_0,_1) -> + case <_0,_1> of + <[{'kernelProcess','application_controller',%% Line 1641 + {'application_controller','start',[App|[]]}}|%% Line 1641 + T],%% Line 1641 + Res> when 'true' -> + %% Line 1642 + apply 'get_appls'/2 + (T, [App|Res]) + %% Line 1644 + <[{'apply',{'application','load',[App|[]]}}|T],Res> when 'true' -> + %% Line 1645 + apply 'get_appls'/2 + (T, [App|Res]) + %% Line 1646 + <[_4|T],Res> when 'true' -> + %% Line 1647 + apply 'get_appls'/2 + (T, Res) + %% Line 1648 + <[],Res> when 'true' -> + %% Line 1649 + Res + ( <_3,_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3,_2}) + -| [{'function_name',{'get_appls',2}}] ) + -| ['compiler_generated'] ) + end +'mon_nodes'/1 = + %% Line 1652 + fun (_0) -> + case _0 of + <'true'> when 'true' -> + let <_4> = + call %% Line 1653 + 'net_kernel':%% Line 1653 + 'monitor_nodes' + (%% Line 1653 + 'true') + in %% Line 1653 + case _4 of + <'ok'> when 'true' -> + ( _4 + -| ['compiler_generated'] ) + ( <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + -| ['compiler_generated'] ) + end + %% Line 1654 + <'false'> when 'true' -> + %% Line 1655 + case call 'net_kernel':'monitor_nodes' + ('false') of + <'ok'> when 'true' -> + %% Line 1656 + apply 'flush'/0 + () + ( <_2> when 'true' -> + primop 'match_fail' + ({'badmatch',_2}) + -| ['compiler_generated'] ) + end + ( <_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3}) + -| [{'function_name',{'mon_nodes',1}}] ) + -| ['compiler_generated'] ) + end +'flush'/0 = + %% Line 1658 + fun () -> + %% Line 1659 + receive + %% Line 1660 + <{'nodedown',_0}> when 'true' -> + apply 'flush'/0 + () + %% Line 1661 + <{'nodeup',_1}> when 'true' -> + apply 'flush'/0 + () + after %% Line 1663 + 0 -> + %% Line 1663 + 'ok' +'prepare_restart_nt'/3 = + %% Line 1666 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <{'release',_30,Vsn,EVsn,_31,_32},%% Line 1667 + {'release',_33,PermVsn,PermEVsn,_34,_35},%% Line 1668 + DataFileName> when 'true' -> + let <_4> = + call %% Line 1669 + 'erlang':%% Line 1669 + 'node' + () + in let <_5> = + call %% Line 1669 + 'erlang':%% Line 1669 + 'atom_to_list' + (_4) + in let <_6> = + call %% Line 1669 + 'string':%% Line 1669 + 'lexemes' + (_5, %% Line 1669 + [64]) + in let <_7> = + call %% Line 1669 + 'erlang':%% Line 1669 + 'hd' + (_6) + in let <_3> = + [95|%% Line 1670 + PermVsn] + in let = + call %% Line 1670 + 'erlang':%% Line 1670 + '++' + (_7, _3) + in let <_10> = + call %% Line 1671 + 'erlang':%% Line 1671 + 'node' + () + in let <_11> = + call %% Line 1671 + 'erlang':%% Line 1671 + 'atom_to_list' + (_10) + in let <_12> = + call %% Line 1671 + 'string':%% Line 1671 + 'lexemes' + (_11, %% Line 1671 + [64]) + in let <_13> = + call %% Line 1671 + 'erlang':%% Line 1671 + 'hd' + (_12) + in let <_9> = + [95|%% Line 1672 + Vsn] + in let = + call %% Line 1672 + 'erlang':%% Line 1672 + '++' + (_13, _9) + in let <_16> = + case %% Line 1673 + call 'erlsrv':'get_service' + (PermEVsn, CurrentServiceName) of + %% Line 1674 + when 'true' -> + %% Line 1675 + call 'erlang':'throw' + (Error1) + %% Line 1676 + when 'true' -> + %% Line 1677 + CS + end + in let <_18> = + call %% Line 1681 + 'filename':%% Line 1681 + 'nativename' + (%% Line 1681 + DataFileName) + in let = + call %% Line 1679 + 'erlsrv':%% Line 1679 + 'new_service' + (%% Line 1679 + FutureServiceName, _16, _18, %% Line 1687 + CurrentServiceName) + in %% Line 1689 + case call 'erlsrv':'store_service' + (EVsn, FutureService) of + %% Line 1690 + when 'true' -> + %% Line 1691 + call 'erlang':'throw' + (Error2) + %% Line 1692 + <_X_X> when 'true' -> + %% Line 1693 + case call 'erlsrv':'disable_service' + (EVsn, FutureServiceName) of + <{'ok',_38}> when 'true' -> + let <_21> = + call %% Line 1694 + 'erlsrv':%% Line 1694 + 'erlsrv' + (%% Line 1694 + EVsn) + in let = + call %% Line 1694 + 'filename':%% Line 1694 + 'nativename' + (_21) + in let <_23> = + call %% Line 1695 + 'erlang':%% Line 1695 + '++' + (%% Line 1695 + [32|[115|[116|[97|[114|[116|[95|[100|[105|[115|[97|[98|[108|[101|[100|[32]]]]]]]]]]]]]]]], %% Line 1695 + FutureServiceName) + in let = + call %% Line 1695 + 'erlang':%% Line 1695 + '++' + (%% Line 1695 + ErlSrv, _23) + in %% Line 1696 + case call 'heart':'set_cmd' + (StartDisabled) of + %% Line 1697 + <'ok'> when 'true' -> + %% Line 1698 + 'ok' + %% Line 1699 + when 'true' -> + %% Line 1700 + call 'erlang':'throw' + ({'error',{'heart:set_cmd() error',Error3}}) + end + ( <_20> when 'true' -> + primop 'match_fail' + ({'badmatch',_20}) + -| ['compiler_generated'] ) + end + end + ( <_29,_28,_27> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_29,_28,_27}) + -| [{'function_name',{'prepare_restart_nt',3}}] ) + -| ['compiler_generated'] ) + end +'prepare_restart_new_emulator'/7 = + %% Line 1708 + fun (_0,_1,_2,_3,_4,_5,_6) -> + %% Line 1710 + case call 'lists':'keysearch' + ('permanent', 6, _5) of + <{'value',PRelease}> when 'true' -> + let = + apply %% Line 1711 + 'set_status'/3 + (_3, %% Line 1711 + 'current', _5) + in let = + apply %% Line 1712 + 'set_status'/3 + (_3, %% Line 1712 + 'tmp_current', %% Line 1712 + NReleases1) + in do %% Line 1713 + apply 'write_releases'/3 + (_2, NReleases2, _6) + %% Line 1714 + apply 'prepare_restart_new_emulator'/6 + (_0, _1, _2, _4, %% Line 1715 + PRelease, _6) + ( <_7> when 'true' -> + primop 'match_fail' + ({'badmatch',_7}) + -| ['compiler_generated'] ) + end +'prepare_restart_new_emulator'/6 = + %% Line 1717 + fun (_0,_1,_2,_3,_4,_5) -> + %% Line 1719 + case _3 of + <{'release',_21,Vsn,EVsn,_22,_23}> when 'true' -> + let <_7> = + [32|%% Line 1720 + Vsn] + in let = + call %% Line 1720 + 'erlang':%% Line 1720 + '++' + (%% Line 1720 + EVsn, _7) + in let = + apply %% Line 1721 + 'write_new_start_erl'/3 + (%% Line 1721 + Data, _2, _5) + in %% Line 1723 + case call 'os':'type' + () of + %% Line 1724 + <{'win32','nt'}> when 'true' -> + do %% Line 1725 + apply 'write_ini_file'/3 + (_1, EVsn, _5) + %% Line 1726 + apply 'prepare_restart_nt'/3 + (_3, _4, DataFile) + %% Line 1727 + <{'unix',_24}> when 'true' -> + let = + apply %% Line 1728 + 'check_start_prg'/2 + (_0, _5) + in let <_11> = + [32|%% Line 1729 + DataFile] + in let <_12> = + call %% Line 1729 + 'erlang':%% Line 1729 + '++' + (%% Line 1729 + StartP, _11) + in %% Line 1729 + case call 'heart':'set_cmd' + (_12) of + %% Line 1730 + <'ok'> when 'true' -> + %% Line 1731 + 'ok' + %% Line 1732 + when 'true' -> + %% Line 1733 + call 'erlang':'throw' + ({'error',{'heart:set_cmd() error',Error}}) + end + ( <_14> when 'true' -> + primop 'match_fail' + ({'case_clause',_14}) + -| ['compiler_generated'] ) + end + ( <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + -| ['compiler_generated'] ) + end +'check_start_prg'/2 = + %% Line 1737 + fun (_0,_1) -> + case <_0,_1> of + <{'do_check',StartPrg},Masters> when 'true' -> + do %% Line 1738 + apply 'check_file'/3 + (StartPrg, 'regular', Masters) + %% Line 1739 + StartPrg + %% Line 1740 + <{_4,StartPrg},_5> when 'true' -> + %% Line 1741 + StartPrg + ( <_3,_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3,_2}) + -| [{'function_name',{'check_start_prg',2}}] ) + -| ['compiler_generated'] ) + end +'write_new_start_erl'/3 = + %% Line 1743 + fun (_0,_1,_2) -> + let = + call %% Line 1744 + 'filename':%% Line 1744 + 'join' + (%% Line 1744 + [_1|[[110|[101|[119|[95|[115|[116|[97|[114|[116|[95|[101|[114|[108|[46|[100|[97|[116|[97]]]]]]]]]]]]]]]]]]]]) + in do %% Line 1745 + apply 'write_file'/3 + (DataFile, _0, _2) + %% Line 1746 + DataFile +'transform_release'/3 = + %% Line 1759 + fun (_0,_1,_2) -> + %% Line 1760 + case call 'init':'script_id' + () of + %% Line 1761 + <_@r0 = {Name,TmpVsn = [95|[95|[110|[101|[119|[95|[101|[109|[117|[108|[97|[116|[111|[114|[95|[95|_20]]]]]]]]]]]]]]]]}> when 'true' -> + let = + call %% Line 1766 + 'lists':%% Line 1766 + 'keydelete' + (%% Line 1766 + TmpVsn, %% Line 1766 + 3, _1) + in do %% Line 1767 + apply 'write_releases'/3 + (_0, DReleases, _2) + %% Line 1768 + apply 'set_current'/2 + (_@r0, _1) + %% Line 1769 + when 'true' -> + let = + fun (_12) -> + %% Line 1770 + case _12 of + + when ( try + let <_8> = + call 'erlang':'element' + (6, Release) + in call 'erlang':'=:=' + (_8, 'tmp_current') + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + %% Line 1771 + case Release of + <{'release',_26,_27,_28,_29,_30}> when 'true' -> + call 'erlang':'setelement' + (6, Release, 'unpacked') + ( <_31> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 1772 + when 'true' -> + Release + end + in %% Line 1774 + case call 'lists':'map' + (F, _1) of + %% Line 1775 + <_32> + when call 'erlang':'=:=' + (_32, + _1) -> + _1 + %% Line 1777 + when 'true' -> + do %% Line 1778 + apply 'write_releases'/3 + (_0, DReleases, _2) + %% Line 1779 + apply 'set_current'/2 + (ScriptId, _1) + end + end +'set_current'/2 = + %% Line 1783 + fun (_0,_1) -> + let = + fun (_19) -> + %% Line 1784 + case _19 of + + when ( try + let <_6> = + call 'erlang':'element' + (6, Release) + in call 'erlang':'=:=' + (_6, 'tmp_current') + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + %% Line 1785 + case _0 of + %% Line 1786 + <{_X_Name,Vsn}> + when ( try + ( let <_10> = + case ( call ( 'erlang' + -| ['compiler_generated'] ):( 'is_record' + -| ['compiler_generated'] ) + (Release, ( 'release' + -| ['compiler_generated'] ), ( 6 + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + ( 'true' + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + ( 'fail' + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <( _8 + -| ['compiler_generated'] )> when 'true' -> + ( _8 + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + in let <_11> = + call 'erlang':'=:=' + (( _10 + -| ['compiler_generated'] ), 'true') + in let <_12> = + call 'erlang':'element' + (3, Release) + in let <_13> = + call 'erlang':'==' + (_12, Vsn) + in ( call ( 'erlang' + -| ['compiler_generated'] ):( 'and' + -| ['compiler_generated'] ) + (_11, _13) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + %% Line 1787 + case Release of + <{'release',_29,_30,_31,_32,_33}> when 'true' -> + call 'erlang':'setelement' + (6, Release, 'current') + ( <_34> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 1788 + <_35> when 'true' -> + %% Line 1789 + case Release of + <{'release',_36,_37,_38,_39,_40}> when 'true' -> + call 'erlang':'setelement' + (6, Release, 'unpacked') + ( <_41> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + end + %% Line 1791 + when 'true' -> + Release + end + in %% Line 1793 + call 'lists':'map' + (F1, _1) +'check_opt_file'/3 = + %% Line 1802 + fun (_0,_1,_2) -> + let <_3> = + catch + %% Line 1803 + apply 'check_file'/3 + (_0, _1, _2) + in %% Line 1803 + case _3 of + %% Line 1804 + <'ok'> when 'true' -> + %% Line 1805 + 'true' + %% Line 1806 + <_X_Error> when 'true' -> + do %% Line 1807 + call 'io':'format' + ([87|[97|[114|[110|[105|[110|[103|[58|[32|[126|[116|[112|[32|[109|[105|[115|[115|[105|[110|[103|[32|[40|[111|[112|[116|[105|[111|[110|[97|[108|[41|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], [_0|[]]) + %% Line 1808 + 'false' + end +'check_file'/3 = + %% Line 1811 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 1812 + apply 'do_check_file'/2 + (FileName, Type) + %% Line 1813 + when 'true' -> + %% Line 1814 + apply 'check_file_masters'/3 + (FileName, Type, Masters) + end +'check_file_masters'/3 = + %% Line 1817 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + do %% Line 1818 + apply 'do_check_file'/3 + (Master, FileName, Type) + %% Line 1819 + apply 'check_file_masters'/3 + (FileName, Type, Masters) + %% Line 1820 + <_X_FileName,_X_Type,[]> when 'true' -> + %% Line 1821 + 'ok' + ( <_5,_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4,_3}) + -| [{'function_name',{'check_file_masters',3}}] ) + -| ['compiler_generated'] ) + end +'do_check_file'/2 = + %% Line 1824 + fun (_0,_1) -> + %% Line 1825 + case call 'file':'read_file_info' + (_0) of + %% Line 1826 + <{'ok',Info = {'file_info',_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23}}> + when ( try + let <_6> = + call 'erlang':'element' + (3, Info) + in call 'erlang':'==' + (_6, _1) + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + 'ok' + %% Line 1827 + <{'error',_X_Reason}> when 'true' -> + call 'erlang':'throw' + ({'error',{'no_such_file',_0}}) + ( <_8> when 'true' -> + primop 'match_fail' + ({'case_clause',_8}) + -| ['compiler_generated'] ) + end +'do_check_file'/3 = + %% Line 1830 + fun (_0,_1,_2) -> + %% Line 1831 + case call 'rpc':'call' + (_0, 'file', 'read_file_info', [_1|[]]) of + %% Line 1832 + <{'ok',Info = {'file_info',_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25}}> + when ( try + let <_7> = + call 'erlang':'element' + (3, Info) + in call 'erlang':'==' + (_7, _2) + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + 'ok' + %% Line 1833 + <_26> when 'true' -> + call 'erlang':'throw' + ({'error',{'no_such_file',{_0,_1}}}) + end +'extract_rel_file'/3 = + %% Line 1840 + fun (_0,_1,_2) -> + %% Line 1841 + ( call ( 'erl_tar' + -| ['result_not_wanted'] ):( 'extract' + -| ['result_not_wanted'] ) + (_1, ( [( {( 'files' + -| ['result_not_wanted'] ),( [_0|( [] + -| ['result_not_wanted'] )] + -| ['result_not_wanted'] )} + -| ['result_not_wanted'] )|( [( {( 'cwd' + -| ['result_not_wanted'] ),_2} + -| ['result_not_wanted'] )|( ['compressed'] + -| ['result_not_wanted'] )] + -| ['result_not_wanted'] )] + -| ['result_not_wanted'] )) + -| ['result_not_wanted'] ) +'extract_tar'/2 = + %% Line 1843 + fun (_0,_1) -> + %% Line 1844 + case call 'erl_tar':'extract' + (_1, ['keep_old_files'|[{'cwd',_0}|['compressed']]]) of + %% Line 1845 + <'ok'> when 'true' -> + %% Line 1846 + 'ok' + %% Line 1847 + <{'error',{Name,Reason}}> when 'true' -> + %% Line 1848 + call 'erlang':'throw' + ({'error',{'cannot_extract_file',Name,Reason}}) + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end +'write_releases'/3 = + %% Line 1851 + fun (_0,_1,_2) -> + let <_14> = + fun (_12) -> + %% Line 1856 + case _12 of + + when ( try + let <_7> = + call 'erlang':'element' + (6, Release) + in call 'erlang':'=:=' + (_7, 'current') + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + %% Line 1857 + case Release of + <{'release',_24,_25,_26,_27,_28}> when 'true' -> + let <_11> = + call 'erlang':'setelement' + (6, Release, 'unpacked') + in {'true',_11} + ( <_29> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','release'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + %% Line 1858 + <_30> when 'true' -> + %% Line 1859 + 'true' + end + in let = + call %% Line 1856 + 'lists':%% Line 1856 + 'zf' + (_14, _1) + in %% Line 1861 + apply 'write_releases_1'/3 + (_0, NewReleases, _2) +'write_releases_1'/3 = + %% Line 1864 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 1865 + case apply 'do_write_release'/3 + (Dir, [82|[69|[76|[69|[65|[83|[69|[83]]]]]]]], NewReleases) of + %% Line 1866 + <'ok'> when 'true' -> + 'ok' + %% Line 1867 + when 'true' -> + call 'erlang':'throw' + (Error) + end + %% Line 1869 + when 'true' -> + do %% Line 1870 + apply 'all_masters'/1 + (Masters) + %% Line 1871 + apply 'write_releases_m'/3 + (Dir, NewReleases, Masters) + end +'do_write_release'/3 = + %% Line 1873 + fun (_0,_1,_2) -> + let <_3> = + call %% Line 1874 + 'filename':%% Line 1874 + 'join' + (_0, _1) + in %% Line 1874 + case call 'file':'open' + (_3, ['write'|[{'encoding','utf8'}]]) of + %% Line 1875 + <{'ok',Fd}> when 'true' -> + let <_4> = + call %% Line 1877 + 'epp':%% Line 1877 + 'encoding_to_string' + (%% Line 1877 + 'utf8') + in %% Line 1876 + case call 'io':'format' + (Fd, [37|[37|[32|[126|[115|[126|[110|[126|[116|[112|[46|[126|[110]]]]]]]]]]]]], %% Line 1877 + [_4|[_2|[]]]) of + <'ok'> when 'true' -> + let <_11> = + call %% Line 1878 + 'file':%% Line 1878 + 'close' + (%% Line 1878 + Fd) + in %% Line 1878 + case _11 of + <'ok'> when 'true' -> + ( _11 + -| ['compiler_generated'] ) + ( <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + -| ['compiler_generated'] ) + end + ( <_5> when 'true' -> + primop 'match_fail' + ({'badmatch',_5}) + -| ['compiler_generated'] ) + end + %% Line 1879 + <_@r0 = {'error',Reason}> when 'true' -> + %% Line 1880 + _@r0 + ( <_7> when 'true' -> + primop 'match_fail' + ({'case_clause',_7}) + -| ['compiler_generated'] ) + end +'write_releases_m'/3 = + %% Line 1894 + fun (_0,_1,_2) -> + let = + call %% Line 1895 + 'filename':%% Line 1895 + 'join' + (_0, %% Line 1895 + [82|[69|[76|[69|[65|[83|[69|[83]]]]]]]]) + in let = + call %% Line 1896 + 'filename':%% Line 1896 + 'join' + (_0, %% Line 1896 + [82|[69|[76|[69|[65|[83|[69|[83|[46|[98|[97|[99|[107|[117|[112]]]]]]]]]]]]]]]) + in let = + call %% Line 1897 + 'filename':%% Line 1897 + 'join' + (_0, %% Line 1897 + [82|[69|[76|[69|[65|[83|[69|[83|[46|[99|[104|[97|[110|[103|[101]]]]]]]]]]]]]]]) + in do %% Line 1898 + apply 'ensure_RELEASES_exists'/2 + (_2, RelFile) + %% Line 1899 + case apply 'at_all_masters'/4 + (_2, 'release_handler', 'do_copy_files', %% Line 1900 + [RelFile|[[Backup|[Change|[]]]|[]]]) of + %% Line 1901 + <'ok'> when 'true' -> + %% Line 1902 + case apply 'at_all_masters'/4 + (_2, 'release_handler', 'do_write_release', %% Line 1903 + [_0|[[82|[69|[76|[69|[65|[83|[69|[83|[46|[99|[104|[97|[110|[103|[101]]]]]]]]]]]]]]]|[_1|[]]]]) of + %% Line 1904 + <'ok'> when 'true' -> + %% Line 1905 + case apply 'at_all_masters'/4 + (_2, 'file', 'rename', %% Line 1906 + [Change|[RelFile|[]]]) of + %% Line 1907 + <'ok'> when 'true' -> + do %% Line 1908 + apply 'remove_files'/3 + ('all', [Backup|[Change|[]]], _2) + %% Line 1909 + 'ok' + %% Line 1910 + <{'error',{Master,R}}> when 'true' -> + do %% Line 1911 + apply 'takewhile'/5 + (Master, _2, 'file', 'rename', %% Line 1912 + [Backup|[RelFile|[]]]) + do %% Line 1913 + apply 'remove_files'/3 + ('all', [Backup|[Change|[]]], _2) + %% Line 1914 + call 'erlang':'throw' + ({'error',{Master,R,'move_releases'}}) + ( <_6> when 'true' -> + primop 'match_fail' + ({'case_clause',_6}) + -| ['compiler_generated'] ) + end + %% Line 1916 + <{'error',{Master,R}}> when 'true' -> + do %% Line 1917 + apply 'remove_files'/3 + ('all', [Backup|[Change|[]]], _2) + %% Line 1918 + call 'erlang':'throw' + ({'error',{Master,R,'update_releases'}}) + ( <_7> when 'true' -> + primop 'match_fail' + ({'case_clause',_7}) + -| ['compiler_generated'] ) + end + %% Line 1920 + <{'error',{Master,R}}> when 'true' -> + do %% Line 1921 + apply 'remove_files'/3 + (Master, [Backup|[Change|[]]], _2) + %% Line 1922 + call 'erlang':'throw' + ({'error',{Master,R,'backup_releases'}}) + ( <_8> when 'true' -> + primop 'match_fail' + ({'case_clause',_8}) + -| ['compiler_generated'] ) + end +'ensure_RELEASES_exists'/2 = + %% Line 1925 + fun (_0,_1) -> + %% Line 1926 + case apply 'at_all_masters'/4 + (_0, 'release_handler', 'do_ensure_RELEASES', [_1|[]]) of + %% Line 1927 + <'ok'> when 'true' -> + %% Line 1928 + 'ok' + %% Line 1929 + <{'error',{Master,R}}> when 'true' -> + %% Line 1930 + call 'erlang':'throw' + ({'error',{Master,R,'ensure_RELEASES_exists'}}) + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end +'copy_file'/3 = + %% Line 1933 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 1934 + case apply 'do_copy_file'/2 + (File, Dir) of + %% Line 1935 + <'ok'> when 'true' -> + 'ok' + %% Line 1936 + when 'true' -> + call 'erlang':'throw' + (Error) + end + %% Line 1938 + when 'true' -> + do %% Line 1939 + apply 'all_masters'/1 + (Masters) + %% Line 1940 + apply 'copy_file_m'/3 + (File, Dir, Masters) + end +'copy_file_m'/3 = + %% Line 1948 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 1949 + case call 'rpc':'call' + (Master, 'release_handler', 'do_copy_file', [File|[Dir|[]]]) of + %% Line 1950 + <'ok'> when 'true' -> + apply 'copy_file_m'/3 + (File, Dir, Masters) + %% Line 1951 + <{'error',{Reason,F}}> when 'true' -> + call 'erlang':'throw' + ({'error',{Master,Reason,F}}) + %% Line 1952 + when 'true' -> + call 'erlang':'throw' + ({'error',{Master,Other,File}}) + end + %% Line 1954 + <_X_File,_X_Dir,[]> when 'true' -> + %% Line 1955 + 'ok' + ( <_6,_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5,_4}) + -| [{'function_name',{'copy_file_m',3}}] ) + -| ['compiler_generated'] ) + end +'do_copy_file'/2 = + %% Line 1957 + fun (_0,_1) -> + let <_2> = + call %% Line 1958 + 'filename':%% Line 1958 + 'basename' + (_0) + in let = + call %% Line 1958 + 'filename':%% Line 1958 + 'join' + (_1, _2) + in %% Line 1959 + apply 'do_copy_file1'/2 + (_0, File2) +'do_copy_file1'/2 = + %% Line 1961 + fun (_0,_1) -> + %% Line 1962 + case call 'file':'read_file' + (_0) of + %% Line 1963 + <{'ok',Bin}> when 'true' -> + %% Line 1964 + case call 'file':'write_file' + (_1, Bin) of + %% Line 1965 + <'ok'> when 'true' -> + 'ok' + %% Line 1966 + <{'error',Reason}> when 'true' -> + %% Line 1967 + {'error',{Reason,_1}} + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end + %% Line 1969 + <{'error',Reason}> when 'true' -> + %% Line 1970 + {'error',{Reason,_0}} + ( <_3> when 'true' -> + primop 'match_fail' + ({'case_clause',_3}) + -| ['compiler_generated'] ) + end +'do_copy_files'/2 = + %% Line 1976 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + %% Line 1977 + case apply 'do_copy_file1'/2 + (File, ToFile) of + %% Line 1978 + <'ok'> when 'true' -> + apply 'do_copy_files'/2 + (File, ToFiles) + %% Line 1979 + when 'true' -> + Error + end + %% Line 1981 + <_5,[]> when 'true' -> + %% Line 1982 + 'ok' + ( <_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_4,_3}) + -| [{'function_name',{'do_copy_files',2}}] ) + -| ['compiler_generated'] ) + end +'do_copy_files'/1 = + %% Line 1987 + fun (_0) -> + case _0 of + <[{Src,Dest}|Files]> when 'true' -> + %% Line 1988 + case apply 'do_copy_file1'/2 + (Src, Dest) of + %% Line 1989 + <'ok'> when 'true' -> + apply 'do_copy_files'/1 + (Files) + %% Line 1990 + when 'true' -> + Error + end + %% Line 1992 + <[]> when 'true' -> + %% Line 1993 + 'ok' + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'do_copy_files',1}}] ) + -| ['compiler_generated'] ) + end +'do_rename_files'/1 = + %% Line 1998 + fun (_0) -> + case _0 of + <[{Src,Dest}|Files]> when 'true' -> + %% Line 1999 + case call 'file':'rename' + (Src, Dest) of + %% Line 2000 + <'ok'> when 'true' -> + apply 'do_rename_files'/1 + (Files) + %% Line 2001 + when 'true' -> + Error + end + %% Line 2003 + <[]> when 'true' -> + %% Line 2004 + 'ok' + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'do_rename_files',1}}] ) + -| ['compiler_generated'] ) + end +'do_remove_files'/1 = + %% Line 2009 + fun (_0) -> + case _0 of + <[File|Files]> when 'true' -> + do %% Line 2010 + ( call ( 'file' + -| ['result_not_wanted'] ):( 'delete' + -| ['result_not_wanted'] ) + (File) + -| ['result_not_wanted'] ) + %% Line 2011 + apply 'do_remove_files'/1 + (Files) + %% Line 2012 + <[]> when 'true' -> + %% Line 2013 + 'ok' + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'do_remove_files',1}}] ) + -| ['compiler_generated'] ) + end +'do_ensure_RELEASES'/1 = + %% Line 2020 + fun (_0) -> + %% Line 2021 + case call 'file':'read_file_info' + (_0) of + %% Line 2022 + <{'ok',_3}> when 'true' -> + 'ok' + %% Line 2023 + <_4> when 'true' -> + apply 'do_write_file'/2 + (_0, [91|[93|[46|[32]]]]) + end +'make_dir'/2 = + %% Line 2029 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + do %% Line 2030 + ( call ( 'file' + -| ['result_not_wanted'] ):( 'make_dir' + -| ['result_not_wanted'] ) + (Dir) + -| ['result_not_wanted'] ) + %% Line 2031 + 'ok' + %% Line 2032 + when 'true' -> + let <_5> = + fun (_3) -> + %% Line 2033 + call 'rpc':'call' + (_3, 'file', 'make_dir', [Dir|[]]) + in %% Line 2033 + call 'lists':'foreach' + (_5, %% Line 2034 + Masters) + end +'all_masters'/1 = + %% Line 2039 + fun (_0) -> + %% Line 2040 + case call 'rpc':'multicall' + (_0, 'erlang', 'info', ['version']) of + %% Line 2041 + <{_3,[]}> when 'true' -> + 'ok' + %% Line 2042 + <{_4,BadNodes}> when 'true' -> + call 'erlang':'throw' + ({'error',{'bad_masters',BadNodes}}) + ( <_1> when 'true' -> + primop 'match_fail' + ({'case_clause',_1}) + -| ['compiler_generated'] ) + end +'at_all_masters'/4 = + %% Line 2050 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <[Master|Masters],M,F,A> when 'true' -> + %% Line 2051 + case call 'rpc':'call' + (Master, M, F, A) of + %% Line 2052 + <'ok'> when 'true' -> + apply 'at_all_masters'/4 + (Masters, M, F, A) + %% Line 2053 + when 'true' -> + {'error',{Master,Error}} + end + %% Line 2055 + <[],_9,_10,_11> when 'true' -> + %% Line 2056 + 'ok' + ( <_8,_7,_6,_5> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_8,_7,_6,_5}) + -| [{'function_name',{'at_all_masters',4}}] ) + -| ['compiler_generated'] ) + end +'takewhile'/5 = + %% Line 2062 + fun (_0,_1,_2,_3,_4) -> + let <_7> = + fun (_5) -> + %% Line 2063 + ( case ( _5 + -| ['result_not_wanted'] ) of + + when ( call ( 'erlang' + -| ['result_not_wanted'] ):( '==' + -| ['result_not_wanted'] ) + (( _5 + -| ['result_not_wanted'] ), + _0) + -| ['result_not_wanted'] ) -> + %% Line 2064 + ( 'false' + -| ['result_not_wanted'] ) + %% Line 2065 + when 'true' -> + do %% Line 2066 + ( call ( 'rpc' + -| ['result_not_wanted'] ):( 'call' + -| ['result_not_wanted'] ) + (Ma, _2, _3, _4) + -| ['result_not_wanted'] ) + %% Line 2067 + ( 'true' + -| ['result_not_wanted'] ) + end + -| ['result_not_wanted'] ) + in do %% Line 2063 + ( call ( 'lists' + -| ['result_not_wanted'] ):( 'takewhile' + -| ['result_not_wanted'] ) + (_7, _1) + -| ['result_not_wanted'] ) + %% Line 2069 + 'ok' +'consult'/2 = + %% Line 2071 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + call 'file':'consult' + (File) + %% Line 2072 + when 'true' -> + apply 'consult_master'/2 + (Masters, File) + end +'consult_master'/2 = + %% Line 2079 + fun (_0,_1) -> + case <_0,_1> of + <[Master|Ms],File> when 'true' -> + %% Line 2080 + case call 'rpc':'call' + (Master, 'file', 'consult', [File|[]]) of + %% Line 2081 + <{'badrpc',_5}> when 'true' -> + apply 'consult_master'/2 + (Ms, File) + %% Line 2082 + when 'true' -> + Res + end + %% Line 2084 + <[],_X_File> when 'true' -> + %% Line 2085 + {'error','no_master'} + ( <_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_4,_3}) + -| [{'function_name',{'consult_master',2}}] ) + -| ['compiler_generated'] ) + end +'read_file'/2 = + %% Line 2087 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + %% Line 2088 + call 'file':'read_file' + (File) + %% Line 2089 + when 'true' -> + %% Line 2090 + apply 'read_master'/2 + (Masters, File) + end +'write_file'/3 = + %% Line 2092 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 2093 + case call 'file':'write_file' + (File, Data) of + %% Line 2094 + <'ok'> when 'true' -> + 'ok' + %% Line 2095 + when 'true' -> + call 'erlang':'throw' + (Error) + end + %% Line 2097 + when 'true' -> + %% Line 2098 + case apply 'at_all_masters'/4 + (Masters, 'file', 'write_file', [File|[Data|[]]]) of + %% Line 2099 + <'ok'> when 'true' -> + 'ok' + %% Line 2100 + when 'true' -> + call 'erlang':'throw' + (Error) + end + end +'ensure_dir'/2 = + %% Line 2103 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + %% Line 2104 + case call 'filelib':'ensure_dir' + (File) of + %% Line 2105 + <'ok'> when 'true' -> + 'ok' + %% Line 2106 + when 'true' -> + call 'erlang':'throw' + (Error) + end + %% Line 2108 + when 'true' -> + %% Line 2109 + case apply 'at_all_masters'/4 + (Masters, 'filelib', 'ensure_dir', [File|[]]) of + %% Line 2110 + <'ok'> when 'true' -> + 'ok' + %% Line 2111 + when 'true' -> + call 'erlang':'throw' + (Error) + end + end +'remove_dir'/2 = + %% Line 2114 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + %% Line 2115 + apply 'remove_file'/1 + (Dir) + %% Line 2116 + when 'true' -> + %% Line 2117 + case apply 'at_all_masters'/4 + (Masters, 'release_handler', 'remove_file', [Dir|[]]) of + %% Line 2118 + <'ok'> when 'true' -> + 'ok' + %% Line 2119 + when 'true' -> + call 'erlang':'throw' + (Error) + end + end +'remove_files'/3 = + %% Line 2124 + fun (_0,_1,_2) -> + %% Line 2125 + apply 'takewhile'/5 + (_0, _2, 'release_handler', 'do_remove_files', [_1|[]]) +'read_master'/2 = + %% Line 2132 + fun (_0,_1) -> + case <_0,_1> of + <[Master|Ms],File> when 'true' -> + %% Line 2133 + case call 'rpc':'call' + (Master, 'file', 'read_file', [File|[]]) of + %% Line 2134 + <{'badrpc',_5}> when 'true' -> + apply 'read_master'/2 + (Ms, File) + %% Line 2135 + when 'true' -> + Res + end + %% Line 2137 + <[],_X_File> when 'true' -> + %% Line 2138 + {'error','no_master'} + ( <_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_4,_3}) + -| [{'function_name',{'read_master',2}}] ) + -| ['compiler_generated'] ) + end +'write_start'/3 = + %% Line 2143 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 2144 + case apply 'do_write_file'/2 + (File, Data) of + %% Line 2145 + <'ok'> when 'true' -> + 'ok' + %% Line 2146 + when 'true' -> + call 'erlang':'throw' + (Error) + end + %% Line 2148 + when 'true' -> + do %% Line 2149 + apply 'all_masters'/1 + (Masters) + %% Line 2150 + apply 'safe_write_file_m'/3 + (File, Data, Masters) + end +'set_static_files'/3 = + %% Line 2163 + fun (_0,_1,_2) -> + do %% Line 2164 + apply 'all_masters'/1 + (_2) + let = + call %% Line 2167 + 'filename':%% Line 2167 + 'join' + (_0, %% Line 2165 + [115|[116|[97|[114|[116|[46|[98|[111|[111|[116]]]]]]]]]]) + in let = + call %% Line 2168 + 'filename':%% Line 2168 + 'join' + (_1, %% Line 2165 + [115|[116|[97|[114|[116|[46|[98|[111|[111|[116]]]]]]]]]]) + in let = + call %% Line 2169 + 'filename':%% Line 2169 + 'join' + (_1, %% Line 2169 + [115|[116|[97|[114|[116|[46|[98|[97|[99|[107|[117|[112]]]]]]]]]]]]) + in let = + call %% Line 2170 + 'filename':%% Line 2170 + 'join' + (_0, %% Line 2166 + [115|[121|[115|[46|[99|[111|[110|[102|[105|[103]]]]]]]]]]) + in let = + call %% Line 2171 + 'filename':%% Line 2171 + 'join' + (_1, %% Line 2166 + [115|[121|[115|[46|[99|[111|[110|[102|[105|[103]]]]]]]]]]) + in let = + call %% Line 2172 + 'filename':%% Line 2172 + 'join' + (_1, %% Line 2172 + [115|[121|[115|[46|[98|[97|[99|[107|[117|[112]]]]]]]]]]) + in %% Line 2174 + case apply 'at_all_masters'/4 + (_2, 'release_handler', 'do_copy_files', %% Line 2175 + [[{DestBoot,BackupBoot}|%% Line 2176 + [{DestConf,BackupConf}|[]]]|%% Line 2176 + []]) of + %% Line 2177 + <'ok'> when 'true' -> + %% Line 2178 + case apply 'at_all_masters'/4 + (_2, 'release_handler', 'do_copy_files', %% Line 2179 + [[{SrcBoot,DestBoot}|%% Line 2180 + [{SrcConf,DestConf}|[]]]|%% Line 2180 + []]) of + %% Line 2181 + <'ok'> when 'true' -> + do %% Line 2182 + apply 'remove_files'/3 + ('all', [BackupBoot|[BackupConf|[]]], _2) + %% Line 2183 + 'ok' + %% Line 2184 + <{'error',{Master,R}}> when 'true' -> + do %% Line 2185 + apply 'takewhile'/5 + (Master, _2, 'release_handler', 'do_rename_files', %% Line 2186 + [{BackupBoot,DestBoot}|%% Line 2187 + [{BackupConf,DestConf}|[]]]) + do %% Line 2188 + apply 'remove_files'/3 + ('all', [BackupBoot|[BackupConf|[]]], _2) + %% Line 2189 + call 'erlang':'throw' + ({'error',{Master,R,'copy_start_config'}}) + ( <_11> when 'true' -> + primop 'match_fail' + ({'case_clause',_11}) + -| ['compiler_generated'] ) + end + %% Line 2191 + <{'error',{Master,R}}> when 'true' -> + do %% Line 2192 + apply 'remove_files'/3 + (Master, [BackupBoot|[BackupConf|[]]], _2) + %% Line 2193 + call 'erlang':'throw' + ({'error',{Master,R,'backup_start_config'}}) + ( <_12> when 'true' -> + primop 'match_fail' + ({'case_clause',_12}) + -| ['compiler_generated'] ) + end +'write_ini_file'/3 = + %% Line 2203 + fun (_0,_1,_2) -> + let <_3> = + call %% Line 2204 + 'erlang':%% Line 2204 + '++' + (%% Line 2204 + [101|[114|[116|[115|[45]]]]], _1) + in let = + call %% Line 2204 + 'filename':%% Line 2204 + 'join' + (%% Line 2204 + [_0|[_3|[[98|[105|[110]]]]]]) + in let <_5> = + call %% Line 2209 + 'filename':%% Line 2209 + 'nativename' + (%% Line 2209 + BinDir) + in let <_6> = + call %% Line 2210 + 'filename':%% Line 2210 + 'nativename' + (_0) + in let = + call %% Line 2205 + 'io_lib':%% Line 2205 + 'format' + (%% Line 2205 + [91|[101|[114|[108|[97|[110|[103|[93|[126|[110|[66|[105|[110|[100|[105|[114|[61|[126|[116|[115|[126|[110|[80|[114|[111|[103|[110|[97|[109|[101|[61|[101|[114|[108|[126|[110|[82|[111|[111|[116|[100|[105|[114|[61|[126|[116|[115|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 2209 + [_5|%% Line 2210 + [_6|[]]]) + in let = + call %% Line 2211 + 're':%% Line 2211 + 'replace' + (%% Line 2211 + Str0, %% Line 2211 + [92|[92]], %% Line 2211 + [92|[92|[92|[92]]]], %% Line 2211 + [{'return','list'}|['global'|['unicode']]]) + in let = + call %% Line 2212 + 'filename':%% Line 2212 + 'join' + (%% Line 2212 + BinDir, %% Line 2212 + [101|[114|[108|[46|[105|[110|[105]]]]]]]) + in %% Line 2213 + apply 'do_write_ini_file'/3 + (IniFile, Str, _2) +'do_write_ini_file'/3 = + %% Line 2215 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 2216 + case apply 'do_write_file'/3 + (File, Data, [{'encoding','utf8'}]) of + %% Line 2217 + <'ok'> when 'true' -> + 'ok' + %% Line 2218 + when 'true' -> + call 'erlang':'throw' + (Error) + end + %% Line 2220 + when 'true' -> + do %% Line 2221 + apply 'all_masters'/1 + (Masters) + %% Line 2222 + apply 'safe_write_file_m'/4 + (File, Data, [{'encoding','utf8'}], Masters) + end +'safe_write_file_m'/3 = + %% Line 2235 + fun (_0,_1,_2) -> + %% Line 2236 + apply 'safe_write_file_m'/4 + (_0, _1, [], _2) +'safe_write_file_m'/4 = + %% Line 2237 + fun (_0,_1,_2,_3) -> + let = + call %% Line 2238 + 'erlang':%% Line 2238 + '++' + (_0, %% Line 2238 + [46|[98|[97|[99|[107|[117|[112]]]]]]]) + in let = + call %% Line 2239 + 'erlang':%% Line 2239 + '++' + (_0, %% Line 2239 + [46|[99|[104|[97|[110|[103|[101]]]]]]]) + in %% Line 2240 + case apply 'at_all_masters'/4 + (_3, 'release_handler', 'do_copy_files', %% Line 2241 + [_0|[[Backup|[]]|[]]]) of + %% Line 2242 + <'ok'> when 'true' -> + %% Line 2243 + case apply 'at_all_masters'/4 + (_3, 'release_handler', 'do_write_file', %% Line 2244 + [Change|[_1|[_2|[]]]]) of + %% Line 2245 + <'ok'> when 'true' -> + %% Line 2246 + case apply 'at_all_masters'/4 + (_3, 'file', 'rename', %% Line 2247 + [Change|[_0|[]]]) of + %% Line 2248 + <'ok'> when 'true' -> + do %% Line 2249 + apply 'remove_files'/3 + ('all', [Backup|[Change|[]]], _3) + %% Line 2250 + 'ok' + %% Line 2251 + <{'error',{Master,R}}> when 'true' -> + do %% Line 2252 + apply 'takewhile'/5 + (Master, _3, 'file', 'rename', %% Line 2253 + [Backup|[_0|[]]]) + do %% Line 2254 + apply 'remove_files'/3 + ('all', [Backup|[Change|[]]], _3) + let <_7> = + call %% Line 2256 + 'filename':%% Line 2256 + 'basename' + (%% Line 2256 + Change) + in let <_6> = + call %% Line 2257 + 'filename':%% Line 2257 + 'basename' + (_0) + in %% Line 2255 + call 'erlang':'throw' + ({'error',{Master,R,'rename',_7,_6}}) + ( <_8> when 'true' -> + primop 'match_fail' + ({'case_clause',_8}) + -| ['compiler_generated'] ) + end + %% Line 2259 + <{'error',{Master,R}}> when 'true' -> + do %% Line 2260 + apply 'remove_files'/3 + ('all', [Backup|[Change|[]]], _3) + let <_9> = + call %% Line 2261 + 'filename':%% Line 2261 + 'basename' + (%% Line 2261 + Change) + in %% Line 2261 + call 'erlang':'throw' + ({'error',{Master,R,'write',_9}}) + ( <_10> when 'true' -> + primop 'match_fail' + ({'case_clause',_10}) + -| ['compiler_generated'] ) + end + %% Line 2263 + <{'error',{Master,R}}> when 'true' -> + do %% Line 2264 + apply 'remove_files'/3 + (Master, [Backup|[]], _3) + let <_12> = + call %% Line 2266 + 'filename':%% Line 2266 + 'basename' + (_0) + in let <_11> = + call %% Line 2267 + 'filename':%% Line 2267 + 'basename' + (%% Line 2267 + Backup) + in %% Line 2265 + call 'erlang':'throw' + ({'error',{Master,R,'backup',_12,_11}}) + ( <_13> when 'true' -> + primop 'match_fail' + ({'case_clause',_13}) + -| ['compiler_generated'] ) + end +'get_new_libs'/2 = + %% Line 2282 + fun (_0,_1) -> + case <_0,_1> of + <[{App,Vsn,_X_LibDir}|CurrentLibs],NewLibs> when 'true' -> + %% Line 2283 + case call 'lists':'keyfind' + (App, 1, NewLibs) of + %% Line 2284 + + when let <_8> = + call 'erlang':'=:=' + (_6, App) + in let <_9> = + call 'erlang':'=/=' + (NewVsn, Vsn) + in call 'erlang':'and' + (_8, _9) -> + let <_2> = + apply %% Line 2285 + 'get_new_libs'/2 + (%% Line 2285 + CurrentLibs, %% Line 2285 + NewLibs) + in %% Line 2285 + [LibInfo|_2] + %% Line 2286 + <_10> when 'true' -> + %% Line 2287 + apply 'get_new_libs'/2 + (CurrentLibs, NewLibs) + end + %% Line 2289 + <[],_11> when 'true' -> + %% Line 2290 + [] + ( <_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4}) + -| [{'function_name',{'get_new_libs',2}}] ) + -| ['compiler_generated'] ) + end +'get_releases_with_status'/3 = + %% Line 2295 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <[],_6,Acc> when 'true' -> + %% Line 2296 + Acc + %% Line 2297 + <[Head = {_7,_8,_9,ReleaseStatus}|Tail],%% Line 2298 + Status,%% Line 2298 + Acc> + when %% Line 2298 + call 'erlang':'==' + (ReleaseStatus, + Status) -> + %% Line 2299 + apply 'get_releases_with_status'/3 + (Tail, Status, [Head|Acc]) + %% Line 2300 + <[_10|Tail],Status,Acc> when 'true' -> + %% Line 2301 + apply 'get_releases_with_status'/3 + (Tail, Status, Acc) + ( <_5,_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4,_3}) + -| [{'function_name',{'get_releases_with_status',3}}] ) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('release_handler') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('release_handler', _0) +end \ No newline at end of file diff --git a/test/data/sasl/release_handler_1.core b/test/data/sasl/release_handler_1.core new file mode 100644 index 0000000..46b3b70 --- /dev/null +++ b/test/data/sasl/release_handler_1.core @@ -0,0 +1,2032 @@ +module 'release_handler_1' ['check_old_processes'/2, + 'check_script'/2, + 'eval_script'/1, + 'eval_script'/5, + 'get_current_vsn'/1, + 'get_supervised_procs'/0, + 'module_info'/0, + 'module_info'/1] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[114|[101|[108|[101|[97|[115|[101|[95|[104|[97|[110|[100|[108|[101|[114|[95|[49|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]]]]]],1}], + %% Line 27 + 'record' = + %% Line 27 + [{'eval_state',[{'record_field',27,{'atom',27,'bins'},{'nil',27}}|[{'record_field',27,{'atom',27,'stopped'},{'nil',27}}|[{'record_field',27,{'atom',27,'suspended'},{'nil',27}}|[{'record_field',27,{'atom',27,'apps'},{'nil',27}}|[{'record_field',28,{'atom',28,'libdirs'}}|[{'record_field',28,{'atom',28,'unpurged'},{'nil',28}}|[{'record_field',28,{'atom',28,'vsns'},{'nil',28}}|[{'record_field',28,{'atom',28,'newlibs'},{'nil',28}}|[{'record_field',29,{'atom',29,'opts'},{'nil',29}}]]]]]]]]]}]] +'check_script'/2 = + %% Line 51 + fun (_0,_1) -> + case <_0,_1> of + <['restart_new_emulator'|Script],LibDirs> when 'true' -> + %% Line 54 + apply 'do_check_script'/3 + (Script, LibDirs, []) + %% Line 55 + when 'true' -> + let <_2> = + catch + %% Line 56 + apply 'check_old_processes'/2 + (Script, 'soft_purge') + in %% Line 56 + case _2 of + %% Line 57 + <{'ok',PurgeMods}> when 'true' -> + %% Line 58 + apply 'do_check_script'/3 + (Script, LibDirs, PurgeMods) + %% Line 59 + <{'error',Mod}> when 'true' -> + %% Line 60 + {'error',{'old_processes',Mod}} + ( <_3> when 'true' -> + primop 'match_fail' + ({'case_clause',_3}) + -| ['compiler_generated'] ) + end + end +'do_check_script'/3 = + %% Line 63 + fun (_0,_1,_2) -> + %% Line 64 + case apply 'split_instructions'/1 + (_0) of + <{Before,After}> when 'true' -> + let <_9> = + catch + let <_8> = + fun (_5,_4) -> + %% Line 66 + apply 'eval'/2 + (_5, _4) + in %% Line 65 + call 'lists':'foldl' + (_8, %% Line 68 + {'eval_state',[],[],[],[],_1,[],[],[],[]}, %% Line 69 + Before) + in %% Line 65 + case _9 of + %% Line 70 + when ( 'true' + -| ['compiler_generated'] ) -> + let <_10> = + catch + %% Line 71 + apply 'syntax_check_script'/1 + (After) + in %% Line 71 + case _10 of + %% Line 72 + <'ok'> when 'true' -> + %% Line 73 + {'ok',_2} + %% Line 74 + when 'true' -> + %% Line 75 + {'error',Other} + end + %% Line 77 + <_@r0 = {'error',Error}> when 'true' -> + %% Line 78 + _@r0 + %% Line 79 + when 'true' -> + %% Line 80 + {'error',Other} + end + ( <_3> when 'true' -> + primop 'match_fail' + ({'badmatch',_3}) + -| ['compiler_generated'] ) + end +'eval_script'/1 = + %% Line 84 + fun (_0) -> + %% Line 85 + apply 'eval_script'/5 + (_0, [], [], [], []) +'eval_script'/5 = + %% Line 87 + fun (_0,_1,_2,_3,_4) -> + let <_5> = + catch + %% Line 88 + apply 'check_old_processes'/2 + (_0, 'soft_purge') + in %% Line 88 + case _5 of + %% Line 89 + <{'ok',_31}> when 'true' -> + %% Line 90 + case apply 'split_instructions'/1 + (_0) of + <{Before,After}> when 'true' -> + let <_12> = + catch + let <_11> = + fun (_8,_7) -> + %% Line 92 + apply 'eval'/2 + (_8, _7) + in %% Line 91 + call 'lists':'foldl' + (_11, %% Line 94 + {'eval_state',[],[],[],_1,_2,[],[],_3,_4}, %% Line 98 + Before) + in %% Line 91 + case _12 of + %% Line 99 + when ( 'true' + -| ['compiler_generated'] ) -> + let <_13> = + catch + %% Line 100 + apply 'syntax_check_script'/1 + (After) + in %% Line 100 + case _13 of + %% Line 101 + <'ok'> when 'true' -> + let <_19> = + catch + let <_18> = + fun (_15,_14) -> + %% Line 104 + apply 'eval'/2 + (_15, _14) + in %% Line 102 + call 'lists':'foldl' + (_18, %% Line 107 + EvalState2, %% Line 108 + After) + in %% Line 102 + case _19 of + %% Line 109 + when %% Line 110 + ( 'true' + -| ['compiler_generated'] ) -> + %% Line 111 + ( case EvalState4 of + ( <( {'eval_state',_50,_51,_52,_53,_54,_rec0,_55,_56,_57} + -| ['compiler_generated'] )> when 'true' -> + {'ok',_rec0} + -| ['compiler_generated'] ) + ( <_58> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 112 + <'restart_emulator'> when 'true' -> + %% Line 113 + 'restart_emulator' + %% Line 114 + when 'true' -> + %% Line 115 + {'EXIT',Error} + end + %% Line 117 + when 'true' -> + %% Line 118 + {'error',Other} + end + %% Line 120 + <_@r0 = {'error',Error}> when 'true' -> + _@r0 + %% Line 121 + when 'true' -> + {'error',Other} + end + ( <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + -| ['compiler_generated'] ) + end + %% Line 123 + <{'error',Mod}> when 'true' -> + %% Line 124 + {'error',{'old_processes',Mod}} + ( <_25> when 'true' -> + primop 'match_fail' + ({'case_clause',_25}) + -| ['compiler_generated'] ) + end +'split_instructions'/1 = + %% Line 130 + fun (_0) -> + %% Line 131 + apply 'split_instructions'/2 + (_0, []) +'split_instructions'/2 = + %% Line 132 + fun (_0,_1) -> + case <_0,_1> of + <_@r0 = ['point_of_no_return'|T],Before> when 'true' -> + let <_2> = + call %% Line 133 + 'lists':%% Line 133 + 'reverse' + (%% Line 133 + Before) + in %% Line 133 + {_2,_@r0} + %% Line 134 + <[H|T],Before> when 'true' -> + %% Line 135 + apply 'split_instructions'/2 + (T, [H|Before]) + %% Line 136 + <[],Before> when 'true' -> + let <_3> = + call %% Line 137 + 'lists':%% Line 137 + 'reverse' + (%% Line 137 + Before) + in %% Line 137 + {[],_3} + ( <_5,_4> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_5,_4}) + -| [{'function_name',{'split_instructions',2}}] ) + -| ['compiler_generated'] ) + end +'check_old_processes'/2 = + %% Line 161 + fun (_0,_1) -> + let = + call %% Line 162 + 'erlang':%% Line 162 + 'processes' + () + in let <_5> = + fun (_3) -> + %% Line 164 + case _3 of + <{'load',{Mod,PPM,_X_PostPurgeMethod}}> + when call 'erlang':'==' + (PPM, + _1) -> + %% Line 165 + apply 'check_old_code'/3 + (Mod, Procs, _1) + %% Line 166 + <{'remove',{Mod,PPM,_X_PostPurgeMethod}}> + when call 'erlang':'==' + (PPM, + _1) -> + %% Line 167 + apply 'check_old_code'/3 + (Mod, Procs, _1) + %% Line 168 + <_9> when 'true' -> + [] + end + in let <_6> = + call %% Line 163 + 'lists':%% Line 163 + 'flatmap' + (_5, _0) + in %% Line 163 + {'ok',_6} +'check_old_code'/3 = + %% Line 172 + fun (_0,_1,_2) -> + %% Line 173 + case call 'erlang':'check_old_code' + (_0) of + %% Line 174 + <'true'> + when call 'erlang':'=:=' + (_2, + 'soft_purge') -> + %% Line 175 + apply 'do_check_old_code'/2 + (_0, _1) + %% Line 176 + <'true'> + when call 'erlang':'=:=' + (_2, + 'brutal_purge') -> + let <_3> = + catch + %% Line 177 + apply 'do_check_old_code'/2 + (_0, _1) + in %% Line 177 + case _3 of + %% Line 178 + <{'error',_9}> + when call 'erlang':'=:=' + (_9, + _0) -> + [] + %% Line 179 + when 'true' -> + R + end + %% Line 181 + <'false'> when 'true' -> + %% Line 182 + [] + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end +'do_check_old_code'/2 = + %% Line 186 + fun (_0,_1) -> + let <_5> = + fun (_3) -> + %% Line 189 + case call 'erlang':'check_process_code' + (_3, _0) of + %% Line 190 + <'false'> when 'true' -> + 'ok' + %% Line 191 + <'true'> when 'true' -> + call 'erlang':'throw' + ({'error',_0}) + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end + in do %% Line 187 + call 'lists':'foreach' + (_5, _1) + %% Line 195 + [_0|[]] +'syntax_check_script'/1 = + %% Line 200 + fun (_0) -> + case _0 of + <['point_of_no_return'|Script]> when 'true' -> + %% Line 201 + apply 'syntax_check_script'/1 + (Script) + %% Line 202 + <[{'load',{_2,_3,_4}}|Script]> when 'true' -> + %% Line 203 + apply 'syntax_check_script'/1 + (Script) + %% Line 204 + <[{'remove',{_5,_6,_7}}|Script]> when 'true' -> + %% Line 205 + apply 'syntax_check_script'/1 + (Script) + %% Line 206 + <[{'purge',_8}|Script]> when 'true' -> + %% Line 207 + apply 'syntax_check_script'/1 + (Script) + %% Line 208 + <[{'suspend',_9}|Script]> when 'true' -> + %% Line 209 + apply 'syntax_check_script'/1 + (Script) + %% Line 210 + <[{'resume',_10}|Script]> when 'true' -> + %% Line 211 + apply 'syntax_check_script'/1 + (Script) + %% Line 212 + <[{'code_change',_11}|Script]> when 'true' -> + %% Line 213 + apply 'syntax_check_script'/1 + (Script) + %% Line 214 + <[{'code_change',_12,_13}|Script]> when 'true' -> + %% Line 215 + apply 'syntax_check_script'/1 + (Script) + %% Line 216 + <[{'stop',_14}|Script]> when 'true' -> + %% Line 217 + apply 'syntax_check_script'/1 + (Script) + %% Line 218 + <[{'start',_15}|Script]> when 'true' -> + %% Line 219 + apply 'syntax_check_script'/1 + (Script) + %% Line 220 + <[{'sync_nodes',_16,{_17,_18,_19}}|Script]> when 'true' -> + %% Line 221 + apply 'syntax_check_script'/1 + (Script) + %% Line 222 + <[{'sync_nodes',_20,_21}|Script]> when 'true' -> + %% Line 223 + apply 'syntax_check_script'/1 + (Script) + %% Line 224 + <[{'apply',{_22,_23,_24}}|Script]> when 'true' -> + %% Line 225 + apply 'syntax_check_script'/1 + (Script) + %% Line 226 + <['restart_emulator'|Script]> when 'true' -> + %% Line 227 + apply 'syntax_check_script'/1 + (Script) + %% Line 228 + <[Illegal|_X_Script]> when 'true' -> + %% Line 229 + call 'erlang':'throw' + ({'illegal_instruction_after_point_of_no_return',Illegal}) + %% Line 230 + <[]> when 'true' -> + %% Line 231 + 'ok' + ( <_1> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_1}) + -| [{'function_name',{'syntax_check_script',1}}] ) + -| ['compiler_generated'] ) + end +'eval'/2 = + %% Line 309 + fun (_0,_1) -> + case <_0,_1> of + <{'load_object_code',{Lib,LibVsn,Modules}},EvalState> when 'true' -> + %% Line 310 + ( case EvalState of + ( <( {'eval_state',_127,_128,_129,_130,_rec1,_131,_132,_133,_134} + -| ['compiler_generated'] )> when 'true' -> + case call 'lists':'keysearch' + (Lib, 1, _rec1) of + %% Line 311 + <{'value',LibInfo = {_136,_137,LibDir}}> + when let <_138> = + call 'erlang':'=:=' + (_136, Lib) + in let <_139> = + call 'erlang':'=:=' + (_137, LibVsn) + in call 'erlang':'and' + (_138, _139) -> + let = + call %% Line 312 + 'code':%% Line 312 + 'objfile_extension' + () + in let <_17> = + fun (_14,_13) -> + %% Line 314 + case <_14,_13> of + when 'true' -> + let = + call %% Line 315 + 'lists':%% Line 315 + 'concat' + (%% Line 315 + [Mod|[Ext|[]]]) + in let = + call %% Line 316 + 'filename':%% Line 316 + 'join' + (%% Line 316 + [LibDir|[[101|[98|[105|[110]]]]|[File|[]]]]) + in %% Line 317 + case call 'erl_prim_loader':'get_file' + (FName) of + %% Line 318 + <{'ok',Bin,FName2}> when 'true' -> + let = + apply %% Line 319 + 'add_vsns'/3 + (%% Line 319 + Mod, %% Line 319 + Bin, %% Line 319 + Vsns) + in %% Line 320 + {[{Mod,Bin,FName2}|Bins],NVsns} + %% Line 321 + <'error'> when 'true' -> + %% Line 322 + call 'erlang':'throw' + ({'error',{'no_such_file',FName}}) + ( <_12> when 'true' -> + primop 'match_fail' + ({'case_clause',_12}) + -| ['compiler_generated'] ) + end + ( <_16,_15> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_16,_15}) + -| [{'function_name',{'-eval/2-fun-0-',2}}] ) + -| ['compiler_generated'] ) + end + in %% Line 325 + ( case EvalState of + ( <( {'eval_state',_rec2,_140,_141,_142,_143,_144,_145,_146,_147} + -| ['compiler_generated'] )> when 'true' -> + %% Line 326 + ( case EvalState of + ( <( {'eval_state',_149,_150,_151,_152,_153,_154,_rec3,_155,_156} + -| ['compiler_generated'] )> when 'true' -> + case call 'lists':'foldl' + (_17, {_rec2,_rec3}, %% Line 327 + Modules) of + <{NewBins,NewVsns}> when 'true' -> + %% Line 328 + ( case EvalState of + ( <( {'eval_state',_158,_159,_160,_161,_162,_163,_164,_rec4,_165} + -| ['compiler_generated'] )> when 'true' -> + let = + call 'lists':'keystore' + (Lib, 1, _rec4, LibInfo) + in %% Line 329 + case EvalState of + <{'eval_state',_167,_168,_169,_170,_171,_172,_173,_174,_175}> when 'true' -> + let <_23> = + call %% Line 330 + 'erlang':%% Line 330 + 'setelement' + (%% Line 330 + 9, EvalState, %% Line 330 + NewLibs) + in let <_24> = + call %% Line 331 + 'erlang':%% Line 331 + 'setelement' + (%% Line 331 + 8, _23, %% Line 331 + NewVsns) + in call 'erlang':'setelement' + (2, _24, NewBins) + ( <_176> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_166> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_18> when 'true' -> + primop 'match_fail' + ({'badmatch',_18}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_157> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_148> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 332 + <{'value',{_177,LibVsn2,_X_LibDir}}> + when call 'erlang':'=:=' + (_177, + Lib) -> + %% Line 333 + call 'erlang':'throw' + ({'error',{'bad_lib_vsn',Lib,LibVsn2}}) + ( <_26> when 'true' -> + primop 'match_fail' + ({'case_clause',_26}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_135> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 335 + <'point_of_no_return',EvalState> when 'true' -> + let <_30> = + case %% Line 336 + apply 'get_opt'/3 + ('update_paths', EvalState, 'false') of + %% Line 337 + <'false'> when 'true' -> + %% Line 338 + ( case EvalState of + ( <( {'eval_state',_178,_179,_180,_181,_182,_183,_184,_rec6,_185} + -| ['compiler_generated'] )> when 'true' -> + _rec6 + -| ['compiler_generated'] ) + ( <_186> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 339 + <'true'> when 'true' -> + %% Line 340 + ( case EvalState of + ( <( {'eval_state',_187,_188,_189,_190,_rec7,_191,_192,_193,_194} + -| ['compiler_generated'] )> when 'true' -> + _rec7 + -| ['compiler_generated'] ) + ( <_195> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_29> when 'true' -> + %% Line 336 + primop 'match_fail' + ({'case_clause',_29}) + -| ['compiler_generated'] ) + end + in let <_35> = + fun (_33) -> + %% Line 342 + case _33 of + <{Lib,_X_LibVsn,LibDir}> when 'true' -> + let = + call %% Line 343 + 'filename':%% Line 343 + 'join' + (%% Line 343 + LibDir, %% Line 343 + [101|[98|[105|[110]]]]) + in %% Line 344 + call 'code':'replace_path' + (Lib, Ebin) + ( <_34> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_34}) + -| [{'function_name',{'-eval/2-fun-1-',1}}] ) + -| ['compiler_generated'] ) + end + in do %% Line 342 + call 'lists':'foreach' + (_35, _30) + %% Line 347 + EvalState + %% Line 348 + <{'load',{Mod,_X_PrePurgeMethod,PostPurgeMethod}},EvalState> when 'true' -> + %% Line 349 + ( case EvalState of + ( <( {'eval_state',_rec8,_196,_197,_198,_199,_200,_201,_202,_203} + -| ['compiler_generated'] )> when 'true' -> + %% Line 350 + case call 'lists':'keysearch' + (Mod, 1, _rec8) of + <{'value',{_X_Mod,Bin,File}}> when 'true' -> + %% Line 353 + case call 'code':'load_binary' + (Mod, File, Bin) of + <{'module',_205}> when 'true' -> + %% Line 356 + ( case EvalState of + ( <( {'eval_state',_206,_207,_208,_209,_210,_rec9,_211,_212,_213} + -| ['compiler_generated'] )> when 'true' -> + let = + apply 'do_soft_purge'/3 + (Mod, PostPurgeMethod, _rec9) + in let <_rec10> = + call %% Line 357 + 'lists':%% Line 357 + 'keydelete' + (%% Line 357 + Mod, %% Line 357 + 1, _rec8) + in %% Line 357 + case EvalState of + <{'eval_state',_215,_216,_217,_218,_219,_220,_221,_222,_223}> when 'true' -> + let <_46> = + call %% Line 358 + 'erlang':%% Line 358 + 'setelement' + (%% Line 358 + 7, EvalState, %% Line 358 + Unpurged) + in call 'erlang':'setelement' + (2, _46, _rec10) + ( <_224> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_214> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_40> when 'true' -> + primop 'match_fail' + ({'badmatch',_40}) + -| ['compiler_generated'] ) + end + ( <_39> when 'true' -> + primop 'match_fail' + ({'badmatch',_39}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_204> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 359 + <{'remove',{Mod,_X_PrePurgeMethod,PostPurgeMethod}},EvalState> when 'true' -> + do %% Line 362 + call 'code':'purge' + (Mod) + do %% Line 363 + call 'code':'delete' + (Mod) + %% Line 366 + ( case EvalState of + ( <( {'eval_state',_225,_226,_227,_228,_229,_rec12,_230,_231,_232} + -| ['compiler_generated'] )> when 'true' -> + let = + apply 'do_soft_purge'/3 + (Mod, PostPurgeMethod, _rec12) + in %% Line 367 + case EvalState of + <{'eval_state',_234,_235,_236,_237,_238,_239,_240,_241,_242}> when 'true' -> + call 'erlang':'setelement' + (7, EvalState, Unpurged) + ( <_243> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_233> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 368 + <{'purge',Modules},EvalState> when 'true' -> + let <_55> = + fun (_53) -> + %% Line 372 + call 'code':'purge' + (_53) + in do %% Line 372 + call 'lists':'foreach' + (_55, Modules) + %% Line 373 + EvalState + %% Line 374 + <{'suspend',Modules},EvalState> when 'true' -> + let = + apply %% Line 375 + 'get_supervised_procs'/0 + () + in let <_68> = + fun (_65,_64) -> + let <_350,_351> = + case _65 of + %% Line 379 + <{Mod,ModTimeout}> when 'true' -> + %% Line 380 + + %% Line 381 + when 'true' -> + %% Line 382 + + end + in let = + apply %% Line 384 + 'get_opt'/3 + (%% Line 384 + 'suspend_timeout', %% Line 384 + EvalState, ( _351 + -| ['compiler_generated'] )) + in let = + apply %% Line 385 + 'suspend'/3 + (( _350 + -| ['compiler_generated'] ), %% Line 385 + Procs, %% Line 385 + Timeout) + in %% Line 386 + [{( _350 + -| ['compiler_generated'] ),Pids}|_64] + in %% Line 388 + ( case EvalState of + ( <( {'eval_state',_244,_245,_rec14,_246,_247,_248,_249,_250,_251} + -| ['compiler_generated'] )> when 'true' -> + let = + call 'lists':'foldl' + (_68, _rec14, %% Line 389 + Modules) + in %% Line 390 + case EvalState of + <{'eval_state',_253,_254,_255,_256,_257,_258,_259,_260,_261}> when 'true' -> + call 'erlang':'setelement' + (4, EvalState, NewSuspended) + ( <_262> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_252> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 391 + <{'resume',Modules},EvalState> when 'true' -> + let <_81> = + fun (_78,_77) -> + let <_76> = + fun (_74) -> + %% Line 394 + case _74 of + <{Mod2,Pids}> + when call 'erlang':'==' + (Mod2, + _78) -> + do %% Line 395 + apply 'resume'/1 + (Pids) + %% Line 396 + 'false' + %% Line 397 + <_263> when 'true' -> + %% Line 398 + 'true' + end + in %% Line 394 + call 'lists':'filter' + (_76, _77) + in %% Line 402 + ( case EvalState of + ( <( {'eval_state',_264,_265,_rec16,_266,_267,_268,_269,_270,_271} + -| ['compiler_generated'] )> when 'true' -> + let = + call 'lists':'foldl' + (_81, _rec16, %% Line 403 + Modules) + in %% Line 404 + case EvalState of + <{'eval_state',_273,_274,_275,_276,_277,_278,_279,_280,_281}> when 'true' -> + call 'erlang':'setelement' + (4, EvalState, NewSuspended) + ( <_282> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_272> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 405 + <{'code_change',Modules},EvalState> when 'true' -> + %% Line 406 + apply 'eval'/2 + ({'code_change','up',Modules}, EvalState) + %% Line 407 + <{'code_change',Mode,Modules},EvalState> when 'true' -> + %% Line 408 + ( case EvalState of + ( <( {'eval_state',_283,_284,_rec18,_285,_286,_287,_288,_289,_290} + -| ['compiler_generated'] )> when 'true' -> + %% Line 409 + ( case EvalState of + ( <( {'eval_state',_292,_293,_294,_295,_296,_297,_rec19,_298,_299} + -| ['compiler_generated'] )> when 'true' -> + let = + apply %% Line 410 + 'get_opt'/3 + (%% Line 410 + 'code_change_timeout', %% Line 410 + EvalState, %% Line 410 + 'default') + in let <_98> = + fun (_96) -> + %% Line 411 + case _96 of + <{Mod,Extra}> when 'true' -> + let <_93> = + case %% Line 413 + call 'lists':'keysearch' + (Mod, 1, _rec19) of + %% Line 414 + <{'value',{_301,OldVsn,_X_NewVsn}}> + when let <_302> = + call 'erlang':'=:=' + (_301, Mod) + in let <_303> = + call %% Line 415 + 'erlang':%% Line 415 + '=:=' + (%% Line 415 + Mode, %% Line 415 + 'up') + in call 'erlang':'and' + (_302, _303) -> + %% Line 415 + OldVsn + %% Line 416 + <{'value',{_304,_X_OldVsn,NewVsn}}> + when let <_305> = + call 'erlang':'=:=' + (_304, Mod) + in let <_306> = + call %% Line 417 + 'erlang':%% Line 417 + '=:=' + (%% Line 417 + Mode, %% Line 417 + 'down') + in call 'erlang':'and' + (_305, _306) -> + %% Line 417 + {'down',NewVsn} + %% Line 418 + <_307> + when call 'erlang':'=:=' + (Mode, + 'up') -> + 'undefined' + %% Line 419 + <_308> when 'true' -> + {'down','undefined'} + end + in %% Line 421 + case call 'lists':'keysearch' + (Mod, 1, _rec18) of + %% Line 422 + <{'value',{_X_Mod,Pids}}> when 'true' -> + %% Line 423 + apply 'change_code'/5 + (Pids, Mod, _93, Extra, Timeout) + %% Line 424 + <_309> when 'true' -> + 'ok' + end + ( <_97> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_97}) + -| [{'function_name',{'-eval/2-fun-6-',1}}] ) + -| ['compiler_generated'] ) + end + in do %% Line 411 + call 'lists':'foreach' + (_98, %% Line 427 + Modules) + %% Line 428 + EvalState + -| ['compiler_generated'] ) + ( <_300> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_291> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 429 + <{'stop',Modules},EvalState> when 'true' -> + let = + apply %% Line 430 + 'get_supervised_procs'/0 + () + in let <_107> = + fun (_104,_103) -> + let = + apply %% Line 433 + 'stop'/2 + (_104, %% Line 433 + Procs) + in %% Line 434 + [{_104,Procs2}|_103] + in %% Line 436 + ( case EvalState of + ( <( {'eval_state',_310,_rec20,_311,_312,_313,_314,_315,_316,_317} + -| ['compiler_generated'] )> when 'true' -> + let = + call 'lists':'foldl' + (_107, _rec20, %% Line 437 + Modules) + in %% Line 438 + case EvalState of + <{'eval_state',_319,_320,_321,_322,_323,_324,_325,_326,_327}> when 'true' -> + call 'erlang':'setelement' + (3, EvalState, NewStopped) + ( <_328> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_318> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 439 + <{'start',Modules},EvalState> when 'true' -> + let <_120> = + fun (_117,_116) -> + let <_115> = + fun (_113) -> + %% Line 442 + case _113 of + <{Mod2,Procs}> + when call 'erlang':'==' + (Mod2, + _117) -> + do %% Line 443 + apply 'start'/1 + (Procs) + %% Line 444 + 'false' + %% Line 445 + <_329> when 'true' -> + %% Line 446 + 'true' + end + in %% Line 442 + call 'lists':'filter' + (_115, _116) + in %% Line 450 + ( case EvalState of + ( <( {'eval_state',_330,_rec22,_331,_332,_333,_334,_335,_336,_337} + -| ['compiler_generated'] )> when 'true' -> + let = + call 'lists':'foldl' + (_120, _rec22, %% Line 451 + Modules) + in %% Line 452 + case EvalState of + <{'eval_state',_339,_340,_341,_342,_343,_344,_345,_346,_347}> when 'true' -> + call 'erlang':'setelement' + (3, EvalState, NewStopped) + ( <_348> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_338> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + %% Line 453 + <{'sync_nodes',Id,{M,F,A}},EvalState> when 'true' -> + let <_124> = + call %% Line 454 + 'erlang':%% Line 454 + 'apply' + (%% Line 454 + M, %% Line 454 + F, %% Line 454 + A) + in do %% Line 454 + apply 'sync_nodes'/2 + (Id, _124) + %% Line 455 + EvalState + %% Line 456 + <{'sync_nodes',Id,Nodes},EvalState> when 'true' -> + do %% Line 457 + apply 'sync_nodes'/2 + (Id, Nodes) + %% Line 458 + EvalState + %% Line 459 + <{'apply',{M,F,A}},EvalState> when 'true' -> + do %% Line 460 + call 'erlang':'apply' + (M, F, A) + %% Line 461 + EvalState + %% Line 462 + <'restart_emulator',_X_EvalState> when 'true' -> + %% Line 463 + call 'erlang':'throw' + ('restart_emulator') + %% Line 464 + <'restart_new_emulator',_X_EvalState> when 'true' -> + %% Line 465 + call 'erlang':'throw' + ('restart_new_emulator') + ( <_126,_125> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_126,_125}) + -| [{'function_name',{'eval',2}}] ) + -| ['compiler_generated'] ) + end +'get_opt'/3 = + %% Line 467 + fun (_0,_1,_2) -> + %% Line 468 + ( case _1 of + ( <( {'eval_state',_9,_10,_11,_12,_13,_14,_15,_16,_rec24} + -| ['compiler_generated'] )> when 'true' -> + case call 'lists':'keysearch' + (_0, 1, _rec24) of + %% Line 469 + <{'value',{_X_Tag,Value}}> when 'true' -> + Value + %% Line 470 + <'false'> when 'true' -> + _2 + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + ( <_17> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','eval_state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'suspend'/3 = + %% Line 481 + fun (_0,_1,_2) -> + let <_8> = + fun (_6) -> + %% Line 482 + case _6 of + <{_X_Sup,_X_Name,Pid,Mods}> when 'true' -> + %% Line 483 + case call 'lists':'member' + (_0, Mods) of + %% Line 484 + <'true'> when 'true' -> + let <_3> = + catch + %% Line 485 + apply 'sys_suspend'/2 + (Pid, _2) + in %% Line 485 + case _3 of + %% Line 486 + <'ok'> when 'true' -> + {'true',Pid} + %% Line 487 + <_12> when 'true' -> + do try + %% Line 490 + call 'sys':'resume' + (Pid) + of <_catch_value> -> + _catch_value + catch -> + 'ok' + %% Line 491 + 'false' + end + %% Line 493 + <'false'> when 'true' -> + %% Line 494 + 'false' + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end + ( <_7> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_7}) + -| [{'function_name',{'-suspend/3-fun-0-',1}}] ) + -| ['compiler_generated'] ) + end + in %% Line 482 + call 'lists':'zf' + (_8, _1) +'sys_suspend'/2 = + %% Line 499 + fun (_0,_1) -> + case <_0,_1> of + when 'true' -> + %% Line 500 + call 'sys':'suspend' + (Pid) + %% Line 501 + when 'true' -> + %% Line 502 + call 'sys':'suspend' + (Pid, Timeout) + end +'resume'/1 = + %% Line 504 + fun (_0) -> + let <_3> = + fun (_1) -> + catch + %% Line 505 + call 'sys':'resume' + (_1) + in %% Line 505 + call 'lists':'foreach' + (_3, _0) +'change_code'/5 = + %% Line 507 + fun (_0,_1,_2,_3,_4) -> + let = + fun (_6) -> + %% Line 509 + case apply 'sys_change_code'/5 + (_6, _1, _2, _3, _4) of + %% Line 510 + <'ok'> when 'true' -> + %% Line 511 + 'ok' + %% Line 512 + <{'error',Reason}> when 'true' -> + %% Line 513 + call 'erlang':'throw' + ({'code_change_failed',_6,_1,_2,Reason}) + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end + in %% Line 516 + call 'lists':'foreach' + (Fun, _0) +'sys_change_code'/5 = + %% Line 518 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + when 'true' -> + %% Line 519 + call 'sys':'change_code' + (Pid, Mod, Vsn, Extra) + %% Line 520 + when 'true' -> + %% Line 521 + call 'sys':'change_code' + (Pid, Mod, Vsn, Extra, Timeout) + end +'stop'/2 = + %% Line 523 + fun (_0,_1) -> + let <_7> = + fun (_5) -> + %% Line 524 + case _5 of + <{'undefined',_X_Name,_X_Pid,_X_Mods}> when 'true' -> + %% Line 525 + 'false' + %% Line 526 + <{Sup,Name,_X_Pid,Mods}> when 'true' -> + %% Line 527 + case call 'lists':'member' + (_0, Mods) of + %% Line 528 + <'true'> when 'true' -> + let <_2> = + catch + %% Line 529 + call 'supervisor':'terminate_child' + (%% Line 530 + Sup, %% Line 530 + Name) + in %% Line 529 + case _2 of + %% Line 531 + <'ok'> when 'true' -> + {'true',{Sup,Name}} + %% Line 532 + <_10> when 'true' -> + 'false' + end + %% Line 534 + <'false'> when 'true' -> + 'false' + ( <_4> when 'true' -> + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end + ( <_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6}) + -| [{'function_name',{'-stop/2-fun-0-',1}}] ) + -| ['compiler_generated'] ) + end + in %% Line 524 + call 'lists':'zf' + (_7, _1) +'start'/1 = + %% Line 539 + fun (_0) -> + let <_3> = + fun (_1) -> + %% Line 540 + case _1 of + <{Sup,Name}> when 'true' -> + catch + %% Line 541 + call 'supervisor':'restart_child' + (Sup, Name) + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'-start/1-fun-0-',1}}] ) + -| ['compiler_generated'] ) + end + in %% Line 540 + call 'lists':'foreach' + (_3, _0) +'get_supervised_procs'/0 = + %% Line 579 + fun () -> + let <_6> = + fun (_3,_2) -> + let <_1> = + call %% Line 584 + 'application_controller':%% Line 584 + 'get_master' + (_3) + in %% Line 582 + apply 'get_master_procs'/3 + (_3, _2, _1) + in let <_0> = + apply %% Line 587 + 'get_application_names'/0 + () + in %% Line 580 + call 'lists':'foldl' + (_6, %% Line 586 + [], _0) +'get_supervised_procs'/4 = + %% Line 589 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + <_12,Root,Procs,{'ok',SupMod}> when 'true' -> + let <_4> = + apply %% Line 590 + 'maybe_supervisor_which_children'/3 + (%% Line 590 + Root, %% Line 590 + SupMod, %% Line 590 + Root) + in let <_5> = + apply %% Line 590 + 'get_procs'/2 + (_4, %% Line 590 + Root) + in %% Line 590 + call 'erlang':'++' + (_5, %% Line 591 + [{'undefined','undefined',Root,[SupMod|[]]}|Procs]) + %% Line 592 + when 'true' -> + do %% Line 593 + call 'error_logger':'error_msg' + ([114|[101|[108|[101|[97|[115|[101|[95|[104|[97|[110|[100|[108|[101|[114|[58|[32|[99|[97|[110|[110|[111|[116|[32|[102|[105|[110|[100|[32|[116|[111|[112|[32|[115|[117|[112|[101|[114|[118|[105|[115|[111|[114|[32|[102|[111|[114|[32|[97|[112|[112|[108|[105|[99|[97|[116|[105|[111|[110|[32|[126|[119|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 594 + [Application|[]]) + let <_6> = + apply %% Line 595 + 'maybe_supervisor_which_children'/3 + (%% Line 595 + Root, %% Line 595 + Application, %% Line 595 + Root) + in let <_7> = + apply %% Line 595 + 'get_procs'/2 + (_6, %% Line 595 + Root) + in %% Line 595 + call 'erlang':'++' + (_7, Procs) + ( <_11,_10,_9,_8> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_11,_10,_9,_8}) + -| [{'function_name',{'get_supervised_procs',4}}] ) + -| ['compiler_generated'] ) + end +'get_application_names'/0 = + %% Line 597 + fun () -> + let <_3> = + fun (_1) -> + %% Line 598 + case _1 of + <{Application,_X_Name,_X_Vsn}> when 'true' -> + %% Line 599 + Application + ( <_2> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_2}) + -| [{'function_name',{'-get_application_names/0-fun-0-',1}}] ) + -| ['compiler_generated'] ) + end + in let <_0> = + call %% Line 601 + 'application':%% Line 601 + 'which_applications' + () + in %% Line 598 + call 'lists':'map' + (_3, _0) +'get_master_procs'/3 = + %% Line 603 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + + when call 'erlang':'is_pid' + (Pid) -> + %% Line 604 + case call 'application_master':'get_child' + (Pid) of + <{Root,_X_AppMod}> when 'true' -> + let <_4> = + apply %% Line 605 + 'get_supervisor_module'/1 + (%% Line 605 + Root) + in %% Line 605 + apply 'get_supervised_procs'/4 + (Application, Root, Procs, _4) + ( <_3> when 'true' -> + primop 'match_fail' + ({'badmatch',_3}) + -| ['compiler_generated'] ) + end + %% Line 606 + <_8,Procs,_9> when 'true' -> + %% Line 607 + Procs + end +'get_procs'/2 = + %% Line 609 + fun (_0,_1) -> + case <_0,_1> of + <[{Name,Pid,'worker','dynamic'}|T],Sup> + when call 'erlang':'is_pid' + (Pid) -> + let = + apply %% Line 610 + 'maybe_get_dynamic_mods'/2 + (%% Line 610 + Name, %% Line 610 + Pid) + in let <_3> = + apply %% Line 611 + 'get_procs'/2 + (%% Line 611 + T, %% Line 611 + Sup) + in %% Line 611 + [{Sup,Name,Pid,Mods}|_3] + %% Line 612 + <[{Name,Pid,'worker',Mods}|T],Sup> + when let <_4> = + call 'erlang':'is_pid' + (Pid) + in let <_5> = + call 'erlang':'is_list' + (Mods) + in call 'erlang':'and' + (_4, _5) -> + let <_6> = + apply %% Line 613 + 'get_procs'/2 + (%% Line 613 + T, %% Line 613 + Sup) + in %% Line 613 + [{Sup,Name,Pid,Mods}|_6] + %% Line 614 + <[{Name,Pid,'supervisor',Mods}|T],Sup> + when call 'erlang':'is_pid' + (Pid) -> + let <_9> = + apply %% Line 615 + 'get_procs'/2 + (%% Line 615 + T, %% Line 615 + Sup) + in let <_7> = + apply %% Line 616 + 'maybe_supervisor_which_children'/3 + (%% Line 616 + Pid, %% Line 616 + Name, %% Line 616 + Pid) + in let <_8> = + apply %% Line 616 + 'get_procs'/2 + (_7, %% Line 616 + Pid) + in %% Line 615 + [{Sup,Name,Pid,Mods}|call 'erlang':'++' + (_9, _8)] + %% Line 617 + <[_X_H|T],Sup> when 'true' -> + %% Line 618 + apply 'get_procs'/2 + (T, Sup) + %% Line 619 + <_12,_X_Sup> when 'true' -> + %% Line 620 + [] + end +'maybe_supervisor_which_children'/3 = + %% Line 622 + fun (_0,_1,_2) -> + %% Line 623 + case apply 'get_proc_state'/1 + (_0) of + %% Line 624 + <'noproc'> when 'true' -> + do %% Line 627 + call 'error_logger':'warning_msg' + ([114|[101|[108|[101|[97|[115|[101|[95|[104|[97|[110|[100|[108|[101|[114|[58|[32|[97|[32|[112|[114|[111|[99|[101|[115|[115|[32|[40|[126|[112|[41|[32|[101|[120|[105|[116|[101|[100|[32|[100|[117|[114|[105|[110|[103|[32|[115|[117|[112|[101|[114|[118|[105|[115|[105|[111|[110|[32|[116|[114|[101|[101|[32|[105|[110|[116|[101|[114|[114|[111|[103|[97|[116|[105|[111|[110|[46|[32|[67|[111|[110|[116|[105|[110|[117|[105|[110|[103|[32|[46|[46|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 629 + [_0|[]]) + %% Line 630 + [] + %% Line 632 + <'suspended'> when 'true' -> + do %% Line 633 + call 'error_logger':'error_msg' + ([114|[101|[108|[101|[97|[115|[101|[95|[104|[97|[110|[100|[108|[101|[114|[58|[32|[97|[32|[119|[104|[105|[99|[104|[95|[99|[104|[105|[108|[100|[114|[101|[110|[32|[99|[97|[108|[108|[32|[116|[111|[32|[126|[112|[32|[40|[126|[119|[41|[32|[119|[97|[115|[32|[97|[118|[111|[105|[100|[101|[100|[46|[32|[84|[104|[105|[115|[32|[115|[117|[112|[101|[114|[118|[105|[115|[111|[114|[32|[105|[115|[32|[115|[117|[115|[112|[101|[110|[100|[101|[100|[32|[97|[110|[100|[32|[115|[104|[111|[117|[108|[100|[32|[108|[105|[107|[101|[108|[121|[32|[98|[101|[32|[117|[112|[103|[114|[97|[100|[101|[100|[32|[100|[105|[102|[102|[101|[114|[101|[110|[116|[108|[121|[46|[32|[69|[120|[105|[116|[105|[110|[103|[32|[46|[46|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 636 + [_1|[_2|[]]]) + %% Line 637 + call 'erlang':'error' + ('suspended_supervisor') + %% Line 639 + <'running'> when 'true' -> + let <_3> = + catch + %% Line 640 + call 'supervisor':'which_children' + (_2) + in %% Line 640 + case _3 of + %% Line 641 + + when call 'erlang':'is_list' + (_3) -> + %% Line 642 + Res + %% Line 643 + when 'true' -> + do %% Line 644 + call 'error_logger':'error_msg' + ([114|[101|[108|[101|[97|[115|[101|[95|[104|[97|[110|[100|[108|[101|[114|[58|[32|[126|[112|[126|[110|[101|[114|[114|[111|[114|[32|[100|[117|[114|[105|[110|[103|[32|[97|[32|[119|[104|[105|[99|[104|[95|[99|[104|[105|[108|[100|[114|[101|[110|[32|[99|[97|[108|[108|[32|[116|[111|[32|[126|[112|[32|[40|[126|[119|[41|[46|[32|[91|[83|[116|[97|[116|[101|[58|[32|[114|[117|[110|[110|[105|[110|[103|[93|[32|[69|[120|[105|[116|[105|[110|[103|[32|[46|[46|[46|[32|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 647 + [Other|[_1|[_2|[]]]]) + %% Line 648 + call 'erlang':'error' + ('which_children_failed') + end + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end +'get_proc_state'/1 = + %% Line 652 + fun (_0) -> + %% Line 657 + try + call 'sys':'get_status' + (_0) + of <_1> -> + case _1 of + %% Line 659 + <{'status',_9,{'module',_10},[_11|[State|[_12|[_13|[_14|[]]]]]]}> + when let <_2> = + call 'erlang':'=:=' + (State, 'running') + in let <_3> = + call %% Line 660 + 'erlang':%% Line 660 + '=:=' + (%% Line 660 + State, %% Line 660 + 'suspended') + in call 'erlang':'or' + (_2, _3) -> + %% Line 661 + State + ( <_4> when 'true' -> + primop 'match_fail' + ({'try_clause',_4}) + -| ['compiler_generated'] ) + end + catch <_7,_6,_5> -> + %% Line 662 + case <_7,_6,_5> of + <( 'exit' + -| ['compiler_generated'] ),( {( 'noproc' + -| ['compiler_generated'] ),( {( 'sys' + -| ['compiler_generated'] ),( 'get_status' + -| ['compiler_generated'] ),( [_15|( [] + -| ['compiler_generated'] )] + -| ['compiler_generated'] )} + -| ['compiler_generated'] )} + -| ['compiler_generated'] ),_16> + when call 'erlang':'=:=' + (_15, + _0) -> + %% Line 663 + 'noproc' + ( <_17,_18,_19> when 'true' -> + primop 'raise' + (_19, _18) + -| ['compiler_generated'] ) + end +'maybe_get_dynamic_mods'/2 = + %% Line 666 + fun (_0,_1) -> + let <_3> = + catch + let <_2> = + call %% Line 667 + 'erlang':%% Line 667 + 'self' + () + in %% Line 667 + call 'gen':'call' + (_1, _2, 'get_modules') + in %% Line 667 + case _3 of + %% Line 668 + <{'ok',Res}> when 'true' -> + %% Line 669 + Res + %% Line 670 + when 'true' -> + do %% Line 671 + call 'error_logger':'error_msg' + ([114|[101|[108|[101|[97|[115|[101|[95|[104|[97|[110|[100|[108|[101|[114|[58|[32|[126|[112|[126|[110|[101|[114|[114|[111|[114|[32|[100|[117|[114|[105|[110|[103|[32|[97|[32|[103|[101|[116|[95|[109|[111|[100|[117|[108|[101|[115|[32|[99|[97|[108|[108|[32|[116|[111|[32|[126|[112|[32|[40|[126|[119|[41|[44|[32|[116|[104|[101|[114|[101|[32|[109|[97|[121|[32|[98|[101|[32|[97|[110|[32|[101|[114|[114|[111|[114|[32|[105|[110|[32|[105|[116|[39|[115|[32|[99|[104|[105|[108|[100|[115|[112|[101|[99|[46|[32|[69|[120|[105|[116|[105|[110|[103|[32|[46|[46|[46|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 675 + [Other|[_0|[_1|[]]]]) + %% Line 676 + call 'erlang':'error' + ('get_modules_failed') + end +'get_supervisor_module'/1 = + %% Line 683 + fun (_0) -> + let <_1> = + catch + %% Line 684 + call 'supervisor':'get_callback_module' + (_0) + in %% Line 684 + case _1 of + %% Line 685 + + when call 'erlang':'is_atom' + (_1) -> + %% Line 686 + {'ok',Module} + %% Line 687 + <_X_Other> when 'true' -> + do %% Line 688 + call 'io':'format' + ([126|[119|[58|[32|[114|[101|[97|[115|[111|[110|[58|[32|[126|[119|[126|[110]]]]]]]]]]]]]]]], [_0|[_X_Other|[]]]) + %% Line 689 + {'error','undefined'} + end +'do_soft_purge'/3 = + %% Line 703 + fun (_0,_1,_2) -> + let = + call %% Line 704 + 'code':%% Line 704 + 'soft_purge' + (_0) + in %% Line 705 + case call 'lists':'keymember' + (_0, 1, _2) of + %% Line 706 + <'true'> + when call 'erlang':'=:=' + (IsNoOldProcsLeft, + 'true') -> + call 'lists':'keydelete' + (_0, 1, _2) + %% Line 707 + <'true'> when 'true' -> + _2 + %% Line 708 + <'false'> + when call 'erlang':'=:=' + (IsNoOldProcsLeft, + 'true') -> + _2 + %% Line 709 + <'false'> when 'true' -> + [{_0,_1}|_2] + ( <_4> when 'true' -> + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end +'sync_nodes'/2 = + %% Line 718 + fun (_0,_1) -> + let <_2> = + call %% Line 719 + 'erlang':%% Line 719 + 'node' + () + in let = + call %% Line 719 + 'lists':%% Line 719 + 'delete' + (_2, _1) + in let <_7> = + fun (_5) -> + let <_4> = + call %% Line 721 + 'erlang':%% Line 721 + 'node' + () + in %% Line 721 + call 'erlang':'!' + ({'release_handler',_5}, {'sync_nodes',_0,_4}) + in do %% Line 720 + call 'lists':'foreach' + (_7, %% Line 723 + NNodes) + let <_10> = + fun (_8) -> + %% Line 725 + receive + %% Line 726 + <{'sync_nodes',_13,_14}> + when let <_15> = + call 'erlang':'=:=' + (_13, _0) + in let <_16> = + call 'erlang':'=:=' + (_14, _8) + in call 'erlang':'and' + (_15, _16) -> + %% Line 727 + 'ok' + %% Line 728 + <{'nodedown',_17}> + when call 'erlang':'=:=' + (_17, + _8) -> + %% Line 729 + call 'erlang':'throw' + ({'sync_error',{'nodedown',_8}}) + after 'infinity' -> + 'true' + in %% Line 724 + call 'lists':'foreach' + (_10, %% Line 732 + NNodes) +'add_vsns'/3 = + %% Line 734 + fun (_0,_1,_2) -> + let = + apply %% Line 735 + 'get_current_vsn'/1 + (_0) + in let = + apply %% Line 736 + 'get_vsn'/1 + (_1) + in %% Line 737 + case call 'lists':'keysearch' + (_0, 1, _2) of + %% Line 738 + <{'value',{_11,OldVsn0,NewVsn0}}> + when call 'erlang':'=:=' + (_11, + _0) -> + let <_6> = + apply %% Line 740 + 'replace_undefined'/2 + (%% Line 740 + OldVsn0, %% Line 740 + OldVsn) + in let <_5> = + apply %% Line 741 + 'replace_undefined'/2 + (%% Line 741 + NewVsn0, %% Line 741 + NewVsn) + in %% Line 739 + call 'lists':'keyreplace' + (_0, 1, _2, {_0,_6,_5}) + %% Line 742 + <'false'> when 'true' -> + %% Line 743 + [{_0,OldVsn,NewVsn}|_2] + ( <_7> when 'true' -> + primop 'match_fail' + ({'case_clause',_7}) + -| ['compiler_generated'] ) + end +'replace_undefined'/2 = + %% Line 746 + fun (_0,_1) -> + case <_0,_1> of + <'undefined',Vsn> when 'true' -> + Vsn + %% Line 747 + when 'true' -> + Vsn + end +'get_current_vsn'/1 = + %% Line 761 + fun (_0) -> + let = + call %% Line 762 + 'code':%% Line 762 + 'which' + (_0) + in %% Line 763 + case call 'erl_prim_loader':'get_file' + (File) of + %% Line 764 + <{'ok',Bin,_X_File2}> when 'true' -> + %% Line 765 + apply 'get_vsn'/1 + (Bin) + %% Line 766 + <'error'> when 'true' -> + %% Line 769 + 'undefined' + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end +'get_vsn'/1 = + %% Line 778 + fun (_0) -> + %% Line 779 + case call 'beam_lib':'version' + (_0) of + <{'ok',{_X_Mod,Vsn}}> when 'true' -> + %% Line 780 + case call 'misc_supp':'is_string' + (Vsn) of + %% Line 781 + <'true'> when 'true' -> + %% Line 782 + Vsn + %% Line 783 + <'false'> when 'true' -> + %% Line 786 + case Vsn of + %% Line 787 + <[VsnTerm|[]]> when 'true' -> + %% Line 788 + VsnTerm + %% Line 789 + <_5> when 'true' -> + %% Line 790 + Vsn + end + ( <_3> when 'true' -> + primop 'match_fail' + ({'case_clause',_3}) + -| ['compiler_generated'] ) + end + ( <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('release_handler_1') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('release_handler_1', _0) +end \ No newline at end of file diff --git a/test/data/sasl/sasl.core b/test/data/sasl/sasl.core new file mode 100644 index 0000000..6e6c4c2 --- /dev/null +++ b/test/data/sasl/sasl.core @@ -0,0 +1,540 @@ +module 'sasl' ['init'/1, + 'module_info'/0, + 'module_info'/1, + 'pred'/1, + 'start'/2, + 'stop'/1] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[115|[97|[115|[108|[46|[101|[114|[108]]]]]]]]]]]],1}], + %% Line 32 + 'behaviour' = + %% Line 32 + ['application'], + %% Line 34 + 'record' = + %% Line 34 + [{'state',[{'record_field',34,{'atom',34,'sasl_logger'}}|[{'record_field',34,{'atom',34,'error_logger_mf'}}]]}]] +'start'/2 = + %% Line 36 + fun (_0,_1) -> + case <_0,_1> of + <_8,[]> when 'true' -> + %% Line 37 + case apply 'get_logger_info'/0 + () of + <{Dest,Level}> when 'true' -> + let = + apply %% Line 38 + 'get_error_logger_mf'/0 + () + in do %% Line 39 + apply 'add_sasl_logger'/2 + (Dest, Level) + do %% Line 40 + apply 'add_error_logger_mf'/1 + (Mf) + let = {%% Line 41 + 'state',%% Line 41 + Dest,%% Line 41 + Mf} + in %% Line 42 + case call 'supervisor':'start_link' + ({'local','sasl_sup'}, 'sasl', []) of + %% Line 43 + <{'ok',Pid}> when 'true' -> + {'ok',Pid,State} + %% Line 44 + when 'true' -> + Error + end + ( <_2> when 'true' -> + primop 'match_fail' + ({'badmatch',_2}) + -| ['compiler_generated'] ) + end + ( <_7,_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_7,_6}) + -| [{'function_name',{'start',2}}] ) + -| ['compiler_generated'] ) + end +'stop'/1 = + %% Line 47 + fun (_0) -> + %% Line 48 + ( case _0 of + ( <( {'state',_rec0,_6} + -| ['compiler_generated'] )> when 'true' -> + do apply 'delete_sasl_logger'/1 + (_rec0) + %% Line 49 + ( case _0 of + ( <( {'state',_8,_rec1} + -| ['compiler_generated'] )> when 'true' -> + apply 'delete_error_logger_mf'/1 + (_rec1) + -| ['compiler_generated'] ) + ( <_9> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_7> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','state'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'get_logger_info'/0 = + %% Line 54 + fun () -> + %% Line 55 + case call 'application':'get_env' + ('kernel', 'logger_sasl_compatible') of + %% Line 56 + <{'ok','true'}> when 'true' -> + let <_1> = + apply %% Line 57 + 'get_logger_dest'/0 + () + in let <_0> = + apply %% Line 57 + 'get_logger_level'/0 + () + in %% Line 57 + {_1,_0} + %% Line 58 + <_3> when 'true' -> + %% Line 59 + {'std','undefined'} + end +'get_logger_dest'/0 = + %% Line 62 + fun () -> + %% Line 63 + case call 'application':'get_env' + ('sasl', 'sasl_error_logger') of + %% Line 64 + <{'ok','false'}> when 'true' -> + 'undefined' + %% Line 65 + <{'ok','tty'}> when 'true' -> + 'standard_io' + %% Line 66 + <{'ok',_@r0 = {'file',File}}> + when call 'erlang':'is_list' + (File) -> + _@r0 + %% Line 67 + <{'ok',_@r1 = {'file',File,Modes}}> + when let <_0> = + call 'erlang':'is_list' + (File) + in let <_1> = + call 'erlang':'is_list' + (Modes) + in call 'erlang':'and' + (_0, _1) -> + %% Line 68 + _@r1 + %% Line 69 + <{'ok',Bad}> when 'true' -> + call 'erlang':'exit' + ({'bad_config',{'sasl',{'sasl_logger_dest',Bad}}}) + %% Line 70 + <'undefined'> when 'true' -> + 'standard_io' + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end +'get_logger_level'/0 = + %% Line 73 + fun () -> + %% Line 74 + case call 'application':'get_env' + ('sasl', 'errlog_type') of + %% Line 75 + <{'ok','error'}> when 'true' -> + 'error' + %% Line 76 + <{'ok','progress'}> when 'true' -> + 'info' + %% Line 77 + <{'ok','all'}> when 'true' -> + 'info' + %% Line 78 + <{'ok',Bad}> when 'true' -> + call 'erlang':'exit' + ({'bad_config',{'sasl',{'errlog_type',Bad}}}) + %% Line 79 + <_1> when 'true' -> + 'info' + end +'get_error_logger_mf'/0 = + %% Line 82 + fun () -> + let <_0> = + catch + %% Line 83 + apply 'get_mf'/0 + () + in %% Line 83 + case _0 of + %% Line 84 + <{'EXIT',Reason}> when 'true' -> + %% Line 85 + call 'erlang':'exit' + (Reason) + %% Line 86 + when 'true' -> + %% Line 87 + Mf + end +'get_mf'/0 = + %% Line 90 + fun () -> + let = + apply %% Line 91 + 'get_mf_dir'/0 + () + in let = + apply %% Line 92 + 'get_mf_maxb'/0 + () + in let = + apply %% Line 93 + 'get_mf_maxf'/0 + () + in %% Line 94 + case of + %% Line 95 + <'undefined','undefined','undefined'> when 'true' -> + %% Line 96 + 'undefined' + %% Line 97 + <( 'undefined' + -| ['compiler_generated'] ),_4,_5> when 'true' -> + %% Line 98 + call 'erlang':'exit' + ({'missing_config',{'sasl','error_logger_mf_dir'}}) + %% Line 99 + <_6,( 'undefined' + -| ['compiler_generated'] ),_7> when 'true' -> + %% Line 100 + call 'erlang':'exit' + ({'missing_config',{'sasl','error_logger_mf_maxbytes'}}) + %% Line 101 + <_8,_9,( 'undefined' + -| ['compiler_generated'] )> when 'true' -> + %% Line 102 + call 'erlang':'exit' + ({'missing_config',{'sasl','error_logger_mf_maxfiles'}}) + %% Line 103 + <( _10 + -| ['compiler_generated'] ),( _11 + -| ['compiler_generated'] ),( _12 + -| ['compiler_generated'] )> when 'true' -> + ( {( _10 + -| ['compiler_generated'] ),( _11 + -| ['compiler_generated'] ),( _12 + -| ['compiler_generated'] )} + -| ['compiler_generated'] ) + end +'get_mf_dir'/0 = + %% Line 107 + fun () -> + %% Line 108 + case call 'application':'get_env' + ('sasl', 'error_logger_mf_dir') of + %% Line 109 + <{'ok','false'}> when 'true' -> + 'undefined' + %% Line 110 + <{'ok',Dir}> + when call 'erlang':'is_list' + (Dir) -> + Dir + %% Line 111 + <'undefined'> when 'true' -> + 'undefined' + %% Line 112 + <{'ok',Bad}> when 'true' -> + call 'erlang':'exit' + ({'bad_config',{'sasl',{'error_logger_mf_dir',Bad}}}) + ( <_0> when 'true' -> + primop 'match_fail' + ({'case_clause',_0}) + -| ['compiler_generated'] ) + end +'get_mf_maxb'/0 = + %% Line 115 + fun () -> + %% Line 116 + case call 'application':'get_env' + ('sasl', 'error_logger_mf_maxbytes') of + %% Line 117 + <{'ok',MaxB}> + when call 'erlang':'is_integer' + (MaxB) -> + MaxB + %% Line 118 + <'undefined'> when 'true' -> + 'undefined' + %% Line 119 + <{'ok',Bad}> when 'true' -> + call 'erlang':'exit' + ({'bad_config',{'sasl',{'error_logger_mf_maxbytes',Bad}}}) + ( <_0> when 'true' -> + primop 'match_fail' + ({'case_clause',_0}) + -| ['compiler_generated'] ) + end +'get_mf_maxf'/0 = + %% Line 122 + fun () -> + %% Line 123 + case call 'application':'get_env' + ('sasl', 'error_logger_mf_maxfiles') of + %% Line 124 + <{'ok',MaxF}> + when try + let <_0> = + call 'erlang':'is_integer' + (MaxF) + in let <_1> = + call 'erlang':'>' + (MaxF, 0) + in let <_2> = + call 'erlang':'<' + (MaxF, 256) + in let <_3> = + call 'erlang':'and' + (_1, _2) + in call 'erlang':'and' + (_0, _3) + of -> + Try + catch -> + 'false' -> + MaxF + %% Line 125 + <'undefined'> when 'true' -> + 'undefined' + %% Line 126 + <{'ok',Bad}> when 'true' -> + call 'erlang':'exit' + ({'bad_config',{'sasl',{'error_logger_mf_maxfiles',Bad}}}) + ( <_4> when 'true' -> + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end +'add_sasl_logger'/2 = + %% Line 129 + fun (_0,_1) -> + case <_0,_1> of + <'undefined',_X_Level> when 'true' -> + 'ok' + %% Line 130 + <'std','undefined'> when 'true' -> + 'ok' + %% Line 131 + when 'true' -> + do %% Line 134 + case Level of + %% Line 135 + <'info'> when 'true' -> + apply 'allow_progress'/0 + () + %% Line 136 + <_11> when 'true' -> + 'ok' + end + let <_6> = + ~{%% Line 147 + 'type'=>Dest}~ + in let <_7> = + ~{%% Line 139 + 'level'=>Level,%% Line 140 + 'filter_default'=>'stop',%% Line 141 + 'filters'=>%% Line 142 + [{'remote_gl',{fun 'logger_filters':'remote_gl'/2,'stop'}}|[{'sasl_domain',{fun 'logger_filters':'domain'/2,{'log','equal',['otp'|['sasl']]}}}]],%% Line 147 + 'config'=>_6,%% Line 148 + 'formatter'=>{'logger_formatter',~{'legacy_header'=>'true','single_line'=>'false'}~}}~ + in let <_12> = + call %% Line 138 + 'logger':%% Line 138 + 'add_handler' + (%% Line 138 + 'sasl', %% Line 138 + 'logger_std_h', _7) + in %% Line 138 + case _12 of + <'ok'> when 'true' -> + ( _12 + -| ['compiler_generated'] ) + ( <_8> when 'true' -> + primop 'match_fail' + ({'badmatch',_8}) + -| ['compiler_generated'] ) + end + end +'delete_sasl_logger'/1 = + %% Line 150 + fun (_0) -> + case _0 of + <'undefined'> when 'true' -> + 'ok' + %% Line 151 + <'std'> when 'true' -> + 'ok' + %% Line 152 + <_X_Type> when 'true' -> + do %% Line 153 + ( call ( 'logger' + -| ['result_not_wanted'] ):( 'remove_handler' + -| ['result_not_wanted'] ) + (( 'sasl' + -| ['result_not_wanted'] )) + -| ['result_not_wanted'] ) + %% Line 154 + 'ok' + end +'add_error_logger_mf'/1 = + %% Line 156 + fun (_0) -> + case _0 of + <'undefined'> when 'true' -> + 'ok' + %% Line 157 + <{Dir,MaxB,MaxF}> when 'true' -> + do %% Line 158 + apply 'allow_progress'/0 + () + let <_1> = 'pred'/1 + in let <_2> = + call %% Line 160 + 'log_mf_h':%% Line 160 + 'init' + (%% Line 160 + Dir, %% Line 160 + MaxB, %% Line 160 + MaxF, _1) + in %% Line 159 + call 'error_logger':'add_report_handler' + (%% Line 160 + 'log_mf_h', _2) + ( <_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_3}) + -| [{'function_name',{'add_error_logger_mf',1}}] ) + -| ['compiler_generated'] ) + end +'delete_error_logger_mf'/1 = + %% Line 162 + fun (_0) -> + case _0 of + <'undefined'> when 'true' -> + 'ok' + %% Line 163 + <_2> when 'true' -> + %% Line 164 + call 'error_logger':'delete_report_handler' + ('log_mf_h') + end +'pred'/1 = + %% Line 166 + fun (_0) -> + case _0 of + <{_X_Type,GL,_X_Msg}> + when try + let <_2> = + call 'erlang':'node' + (GL) + in let <_1> = + call 'erlang':'node' + () + in call 'erlang':'=/=' + (_2, _1) + of -> + Try + catch -> + 'false' -> + 'false' + %% Line 167 + <_4> when 'true' -> + 'true' + end +'allow_progress'/0 = + %% Line 169 + fun () -> + %% Line 170 + case call 'logger':'get_primary_config' + () of + <~{'level':=PL}~> when 'true' -> + %% Line 171 + case call 'logger':'compare_levels' + ('info', PL) of + %% Line 172 + <'lt'> when 'true' -> + let <_3> = + call 'logger':'set_primary_config' + ('level', 'info') + in case _3 of + <'ok'> when 'true' -> + ( _3 + -| ['compiler_generated'] ) + ( <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + -| ['compiler_generated'] ) + end + %% Line 173 + <_4> when 'true' -> + 'ok' + end + ( <_0> when 'true' -> + primop 'match_fail' + ({'badmatch',_0}) + -| ['compiler_generated'] ) + end +'init'/1 = + %% Line 179 + fun (_0) -> + case _0 of + <[]> when 'true' -> + %% Line 191 + {'ok',{{'one_for_one',0,1},[{'sasl_safe_sup',{'supervisor','start_link',[{'local','sasl_safe_sup'}|['sasl'|['safe']]]},'permanent','infinity','supervisor',['sasl']}|[{'release_handler',{'release_handler','start_link',[]},'permanent',2000,'worker',[]}]]}} + %% Line 192 + <'safe'> when 'true' -> + %% Line 197 + {'ok',{{'one_for_one',4,3600},[{'alarm_handler',{'alarm_handler','start_link',[]},'permanent',2000,'worker','dynamic'}]}} + ( <_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6}) + -| [{'function_name',{'init',1}}] ) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('sasl') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('sasl', _0) +end \ No newline at end of file diff --git a/test/data/sasl/sasl_report.core b/test/data/sasl/sasl_report.core new file mode 100644 index 0000000..c4e29e1 --- /dev/null +++ b/test/data/sasl/sasl_report.core @@ -0,0 +1,770 @@ +module 'sasl_report' ['format_report'/3, + 'module_info'/0, + 'module_info'/1, + 'write_report'/3] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[115|[97|[115|[108|[95|[114|[101|[112|[111|[114|[116|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]],1}]] +'format_report'/3 = + %% Line 24 + fun (_0,_1,_2) -> + %% Line 25 + apply 'io_report'/4 + ('io_lib', _0, _1, _2) +'write_report'/3 = + %% Line 27 + fun (_0,_1,_2) -> + %% Line 28 + apply 'io_report'/4 + ('io', _0, _1, _2) +'io_report'/4 = + %% Line 30 + fun (_0,_1,_2,_3) -> + case <_0,_1,_2,_3> of + when 'true' -> + %% Line 31 + case apply 'is_my_error_report'/2 + (What, Type) of + %% Line 32 + <'true'> when 'true' -> + let = + apply %% Line 33 + 'write_head'/3 + (%% Line 33 + Type, %% Line 33 + Time, %% Line 33 + Pid) + in %% Line 34 + apply 'write_report2'/5 + (IO, Fd, Head, Type, Report) + %% Line 35 + <_12> when 'true' -> + 'true' + end + %% Line 37 + when 'true' -> + %% Line 38 + case apply 'is_my_info_report'/2 + (What, Type) of + %% Line 39 + <'true'> when 'true' -> + let = + apply %% Line 40 + 'write_head'/3 + (%% Line 40 + Type, %% Line 40 + Time, %% Line 40 + Pid) + in %% Line 41 + apply 'write_report2'/5 + (IO, Fd, Head, Type, Report) + %% Line 42 + <_13> when 'true' -> + 'true' + end + %% Line 44 + <_X_IO,_X_Fd,_14,_15> when 'true' -> + %% Line 45 + 'false' + end +'is_my_error_report'/2 = + %% Line 47 + fun (_0,_1) -> + case <_0,_1> of + <'all',Type> when 'true' -> + apply 'is_my_error_report'/1 + (Type) + %% Line 48 + <'error',Type> when 'true' -> + apply 'is_my_error_report'/1 + (Type) + %% Line 49 + <_4,_X_Type> when 'true' -> + 'false' + end +'is_my_error_report'/1 = + %% Line 51 + fun (_0) -> + case _0 of + <'supervisor_report'> when 'true' -> + 'true' + %% Line 52 + <'crash_report'> when 'true' -> + 'true' + %% Line 53 + <_2> when 'true' -> + 'false' + end +'is_my_info_report'/2 = + %% Line 55 + fun (_0,_1) -> + case <_0,_1> of + <'all',Type> when 'true' -> + apply 'is_my_info_report'/1 + (Type) + %% Line 56 + <'progress',Type> when 'true' -> + apply 'is_my_info_report'/1 + (Type) + %% Line 57 + <_4,_X_Type> when 'true' -> + 'false' + end +'is_my_info_report'/1 = + %% Line 59 + fun (_0) -> + case _0 of + <'progress'> when 'true' -> + 'true' + %% Line 60 + <_2> when 'true' -> + 'false' + end +'write_report2'/5 = + %% Line 62 + fun (_0,_1,_2,_3,_4) -> + case <_0,_1,_2,_3,_4> of + when 'true' -> + let = + apply %% Line 63 + 'sup_get'/2 + (%% Line 63 + 'supervisor', %% Line 63 + Report) + in let = + apply %% Line 64 + 'sup_get'/2 + (%% Line 64 + 'errorContext', %% Line 64 + Report) + in let = + apply %% Line 65 + 'sup_get'/2 + (%% Line 65 + 'reason', %% Line 65 + Report) + in let = + apply %% Line 66 + 'sup_get'/2 + (%% Line 66 + 'offender', %% Line 66 + Report) + in let = + apply %% Line 67 + 'encoding'/1 + (%% Line 67 + Fd) + in %% Line 68 + case apply 'supervisor_format'/2 + ([Name|[Context|[Reason|[Offender|[]]]]], Enc) of + <{FmtString,Args}> when 'true' -> + let = + call %% Line 69 + 'io_lib':%% Line 69 + 'format' + (%% Line 69 + FmtString, %% Line 69 + Args) + in %% Line 70 + apply 'write_report_action'/4 + (IO, Fd, Head, String) + ( <_10> when 'true' -> + primop 'match_fail' + ({'badmatch',_10}) + -| ['compiler_generated'] ) + end + %% Line 71 + when 'true' -> + let = + apply %% Line 72 + 'encoding'/1 + (%% Line 72 + Fd) + in let = + call %% Line 73 + 'error_logger':%% Line 73 + 'get_format_depth' + () + in let = + apply %% Line 74 + 'format_key_val'/3 + (%% Line 74 + Report, %% Line 74 + Encoding, %% Line 74 + Depth) + in %% Line 75 + apply 'write_report_action'/4 + (IO, Fd, Head, String) + %% Line 76 + when 'true' -> + let = + apply %% Line 77 + 'encoding'/1 + (%% Line 77 + Fd) + in let = + call %% Line 78 + 'error_logger':%% Line 78 + 'get_format_depth' + () + in let = + call %% Line 79 + 'proc_lib':%% Line 79 + 'format' + (%% Line 79 + Report, %% Line 79 + Encoding, %% Line 79 + Depth) + in %% Line 80 + apply 'write_report_action'/4 + (IO, Fd, Head, String) + ( <_22,_21,_20,_19,_18> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_22,_21,_20,_19,_18}) + -| [{'function_name',{'write_report2',5}}] ) + -| ['compiler_generated'] ) + end +'supervisor_format'/2 = + %% Line 82 + fun (_0,_1) -> + let <_2> = + call %% Line 83 + 'error_logger':%% Line 83 + 'get_format_depth' + () + in %% Line 83 + case apply 'p'/2 + (_1, _2) of + <{P,Tl}> when 'true' -> + %% Line 84 + case _0 of + <[A|[B|[C|[D|[]]]]]> when 'true' -> + let <_5> = + [%% Line 85 + C|%% Line 85 + call 'erlang':'++' + (Tl, [D|Tl])] + in let <_6> = + [%% Line 85 + B|%% Line 85 + call 'erlang':'++' + (Tl, _5)] + in let = + [%% Line 85 + A|%% Line 85 + call 'erlang':'++' + (Tl, _6)] + in let <_8> = + call %% Line 89 + 'erlang':%% Line 89 + '++' + (%% Line 89 + P, %% Line 89 + [10|[126|[110]]]) + in let <_9> = + call %% Line 89 + 'erlang':%% Line 89 + '++' + (%% Line 88 + [10|[32|[32|[32|[32|[32|[79|[102|[102|[101|[110|[100|[101|[114|[58|[32|[32|[32|[126|[56|[48|[46|[49|[56]]]]]]]]]]]]]]]]]]]]]]]], _8) + in let <_10> = + call %% Line 88 + 'erlang':%% Line 88 + '++' + (%% Line 88 + P, _9) + in let <_11> = + call %% Line 88 + 'erlang':%% Line 88 + '++' + (%% Line 87 + [10|[32|[32|[32|[32|[32|[82|[101|[97|[115|[111|[110|[58|[32|[32|[32|[32|[32|[126|[56|[48|[46|[49|[56]]]]]]]]]]]]]]]]]]]]]]]], _10) + in let <_12> = + call %% Line 87 + 'erlang':%% Line 87 + '++' + (%% Line 87 + P, _11) + in let <_13> = + call %% Line 87 + 'erlang':%% Line 87 + '++' + (%% Line 86 + [10|[32|[32|[32|[32|[32|[67|[111|[110|[116|[101|[120|[116|[58|[32|[32|[32|[32|[126]]]]]]]]]]]]]]]]]]], _12) + in let <_14> = + call %% Line 86 + 'erlang':%% Line 86 + '++' + (%% Line 86 + P, _13) + in let <_15> = + call %% Line 86 + 'erlang':%% Line 86 + '++' + (%% Line 86 + [32|[32|[32|[32|[32|[83|[117|[112|[101|[114|[118|[105|[115|[111|[114|[58|[32|[126]]]]]]]]]]]]]]]]]], _14) + in %% Line 86 + {_15,%% Line 90 + Args} + ( <_4> when 'true' -> + primop 'match_fail' + ({'badmatch',_4}) + -| ['compiler_generated'] ) + end + ( <_3> when 'true' -> + primop 'match_fail' + ({'badmatch',_3}) + -| ['compiler_generated'] ) + end +'write_report_action'/4 = + %% Line 92 + fun (_0,_1,_2,_3) -> + let = + [_2|_3] + in %% Line 94 + case _0 of + %% Line 95 + <'io'> when 'true' -> + call 'io':'put_chars' + (_1, S) + %% Line 96 + <'io_lib'> when 'true' -> + S + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end +'format_key_val'/3 = + %% Line 99 + fun (_0,_1,_2) -> + %% Line 100 + case apply 'p'/2 + (_1, _2) of + <{P,Tl}> when 'true' -> + %% Line 101 + apply 'format_key_val1'/3 + (_0, P, Tl) + ( <_3> when 'true' -> + primop 'match_fail' + ({'badmatch',_3}) + -| ['compiler_generated'] ) + end +'format_key_val1'/3 = + %% Line 103 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <[{Tag,Data}|Rep],P,Tl> when 'true' -> + let <_4> = + call %% Line 104 + 'erlang':%% Line 104 + '++' + (%% Line 104 + P, %% Line 104 + [10]) + in let <_5> = + call %% Line 104 + 'erlang':%% Line 104 + '++' + (%% Line 104 + [32|[32|[32|[32|[126|[49|[54|[119|[58|[32|[126]]]]]]]]]]], _4) + in let <_6> = + call %% Line 104 + 'io_lib':%% Line 104 + 'format' + (_5, %% Line 104 + [Tag|[Data|Tl]]) + in let <_3> = + apply %% Line 105 + 'format_key_val1'/3 + (%% Line 105 + Rep, %% Line 105 + P, %% Line 105 + Tl) + in %% Line 104 + call 'erlang':'++' + (_6, _3) + %% Line 106 + <_10,_11,_12> when 'true' -> + %% Line 107 + [] + end +'p'/2 = + %% Line 109 + fun (_0,_1) -> + let <_10,_11> = + case _1 of + %% Line 111 + <'unlimited'> when 'true' -> + <[112],[]> + %% Line 112 + <_9> when 'true' -> + <[80],[_1|[]]> + end + in let <_5> = + apply %% Line 114 + 'modifier'/1 + (_0) + in let

= + call %% Line 114 + 'erlang':%% Line 114 + '++' + (_5, ( _10 + -| ['compiler_generated'] )) + in %% Line 115 + {P,( _11 + -| ['compiler_generated'] )} +'encoding'/1 = + %% Line 117 + fun (_0) -> + let <_1> = + call %% Line 118 + 'io':%% Line 118 + 'getopts' + (_0) + in %% Line 118 + case call 'lists':'keyfind' + ('encoding', 1, _1) of + %% Line 119 + <'false'> when 'true' -> + 'latin1' + %% Line 120 + <{'encoding',Enc}> when 'true' -> + Enc + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end +'modifier'/1 = + %% Line 123 + fun (_0) -> + case _0 of + <'latin1'> when 'true' -> + [] + %% Line 124 + <_2> when 'true' -> + [116] + end +'sup_get'/2 = + %% Line 126 + fun (_0,_1) -> + %% Line 127 + case call 'lists':'keysearch' + (_0, 1, _1) of + %% Line 128 + <{'value',{_5,Value}}> when 'true' -> + %% Line 129 + Value + %% Line 130 + <_6> when 'true' -> + %% Line 131 + [] + end +'maybe_utc'/1 = + %% Line 134 + fun (_0) -> + %% Line 135 + case call 'application':'get_env' + ('sasl', 'utc_log') of + %% Line 136 + <{'ok','true'}> when 'true' -> + %% Line 137 + case call 'calendar':'local_time_to_universal_time_dst' + (_0) of + %% Line 138 + <[UTC|[]]> when 'true' -> + %% Line 139 + {'utc',UTC} + %% Line 140 + <[UTC1|[_X_UTC2|[]]]> when 'true' -> + %% Line 141 + {'utc',UTC1} + %% Line 142 + <[]> when 'true' -> + _0 + ( <_1> when 'true' -> + primop 'match_fail' + ({'case_clause',_1}) + -| ['compiler_generated'] ) + end + %% Line 145 + <_4> when 'true' -> + _0 + end +'write_head'/3 = + %% Line 149 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <'supervisor_report',Time,Pid> when 'true' -> + let <_3> = + apply %% Line 150 + 'maybe_utc'/1 + (%% Line 150 + Time) + in %% Line 150 + apply 'write_head1'/3 + ([83|[85|[80|[69|[82|[86|[73|[83|[79|[82|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]]]]]]]], _3, Pid) + %% Line 151 + <'crash_report',Time,Pid> when 'true' -> + let <_4> = + apply %% Line 152 + 'maybe_utc'/1 + (%% Line 152 + Time) + in %% Line 152 + apply 'write_head1'/3 + ([67|[82|[65|[83|[72|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]]], _4, Pid) + %% Line 153 + <'progress',Time,Pid> when 'true' -> + let <_5> = + apply %% Line 154 + 'maybe_utc'/1 + (%% Line 154 + Time) + in %% Line 154 + apply 'write_head1'/3 + ([80|[82|[79|[71|[82|[69|[83|[83|[32|[82|[69|[80|[79|[82|[84]]]]]]]]]]]]]]], _5, Pid) + ( <_8,_7,_6> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_8,_7,_6}) + -| [{'function_name',{'write_head',3}}] ) + -| ['compiler_generated'] ) + end +'write_head1'/3 = + %% Line 156 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + + when try + let <_4> = + call 'erlang':'node' + (Pid) + in let <_3> = + call 'erlang':'node' + () + in call 'erlang':'/=' + (_4, _3) + of -> + Try + catch -> + 'false' -> + let <_5> = + apply %% Line 158 + 'month'/1 + (%% Line 158 + Mo) + in let <_6> = + apply %% Line 158 + 't'/1 + (%% Line 158 + H) + in let <_7> = + apply %% Line 158 + 't'/1 + (%% Line 158 + Mi) + in let <_8> = + apply %% Line 158 + 't'/1 + (%% Line 158 + S) + in let <_9> = + call %% Line 158 + 'erlang':%% Line 158 + 'node' + (%% Line 158 + Pid) + in %% Line 157 + call 'io_lib':'format' + ([126|[110|[61|[126|[115|[61|[61|[61|[61|[32|[126|[112|[45|[126|[115|[45|[126|[112|[58|[58|[126|[115|[58|[126|[115|[58|[126|[115|[32|[85|[84|[67|[32|[40|[126|[112|[41|[32|[61|[61|[61|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 158 + [Type|[D|[_5|[Y|[_6|[_7|[_8|[_9|[]]]]]]]]]) + %% Line 159 + when 'true' -> + let <_10> = + apply %% Line 161 + 'month'/1 + (%% Line 161 + Mo) + in let <_11> = + apply %% Line 161 + 't'/1 + (%% Line 161 + H) + in let <_12> = + apply %% Line 161 + 't'/1 + (%% Line 161 + Mi) + in let <_13> = + apply %% Line 161 + 't'/1 + (%% Line 161 + S) + in %% Line 160 + call 'io_lib':'format' + ([126|[110|[61|[126|[115|[61|[61|[61|[61|[32|[126|[112|[45|[126|[115|[45|[126|[112|[58|[58|[126|[115|[58|[126|[115|[58|[126|[115|[32|[85|[84|[67|[32|[61|[61|[61|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 161 + [Type|[D|[_10|[Y|[_11|[_12|[_13|[]]]]]]]]) + %% Line 162 + + when try + let <_15> = + call 'erlang':'node' + (Pid) + in let <_14> = + call 'erlang':'node' + () + in call 'erlang':'/=' + (_15, _14) + of -> + Try + catch -> + 'false' -> + let <_16> = + apply %% Line 164 + 'month'/1 + (%% Line 164 + Mo) + in let <_17> = + apply %% Line 164 + 't'/1 + (%% Line 164 + H) + in let <_18> = + apply %% Line 164 + 't'/1 + (%% Line 164 + Mi) + in let <_19> = + apply %% Line 164 + 't'/1 + (%% Line 164 + S) + in let <_20> = + call %% Line 164 + 'erlang':%% Line 164 + 'node' + (%% Line 164 + Pid) + in %% Line 163 + call 'io_lib':'format' + ([126|[110|[61|[126|[115|[61|[61|[61|[61|[32|[126|[112|[45|[126|[115|[45|[126|[112|[58|[58|[126|[115|[58|[126|[115|[58|[126|[115|[32|[40|[126|[112|[41|[32|[61|[61|[61|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 164 + [Type|[D|[_16|[Y|[_17|[_18|[_19|[_20|[]]]]]]]]]) + %% Line 165 + when 'true' -> + let <_21> = + apply %% Line 167 + 'month'/1 + (%% Line 167 + Mo) + in let <_22> = + apply %% Line 167 + 't'/1 + (%% Line 167 + H) + in let <_23> = + apply %% Line 167 + 't'/1 + (%% Line 167 + Mi) + in let <_24> = + apply %% Line 167 + 't'/1 + (%% Line 167 + S) + in %% Line 166 + call 'io_lib':'format' + ([126|[110|[61|[126|[115|[61|[61|[61|[61|[32|[126|[112|[45|[126|[115|[45|[126|[112|[58|[58|[126|[115|[58|[126|[115|[58|[126|[115|[32|[61|[61|[61|[126|[110]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], %% Line 167 + [Type|[D|[_21|[Y|[_22|[_23|[_24|[]]]]]]]]) + ( <_27,_26,_25> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_27,_26,_25}) + -| [{'function_name',{'write_head1',3}}] ) + -| ['compiler_generated'] ) + end +'t'/1 = + %% Line 169 + fun (_0) -> + case _0 of + + when call 'erlang':'is_integer' + (_0) -> + let <_1> = + call %% Line 170 + 'erlang':%% Line 170 + 'integer_to_list' + (%% Line 170 + X) + in %% Line 170 + apply 't1'/1 + (_1) + %% Line 171 + <_3> when 'true' -> + %% Line 172 + [] + end +'t1'/1 = + %% Line 173 + fun (_0) -> + case _0 of + <_@r0 = [X|[]]> when 'true' -> + [48|_@r0] + %% Line 174 + when 'true' -> + X + end +'month'/1 = + %% Line 176 + fun (_0) -> + case _0 of + <1> when 'true' -> + [74|[97|[110]]] + %% Line 177 + <2> when 'true' -> + [70|[101|[98]]] + %% Line 178 + <3> when 'true' -> + [77|[97|[114]]] + %% Line 179 + <4> when 'true' -> + [65|[112|[114]]] + %% Line 180 + <5> when 'true' -> + [77|[97|[121]]] + %% Line 181 + <6> when 'true' -> + [74|[117|[110]]] + %% Line 182 + <7> when 'true' -> + [74|[117|[108]]] + %% Line 183 + <8> when 'true' -> + [65|[117|[103]]] + %% Line 184 + <9> when 'true' -> + [83|[101|[112]]] + %% Line 185 + <10> when 'true' -> + [79|[99|[116]]] + %% Line 186 + <11> when 'true' -> + [78|[111|[118]]] + %% Line 187 + <12> when 'true' -> + [68|[101|[99]]] + ( <_1> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_1}) + -| [{'function_name',{'month',1}}] ) + -| ['compiler_generated'] ) + end +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('sasl_report') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('sasl_report', _0) +end \ No newline at end of file diff --git a/test/data/sasl/sasl_report_file_h.core b/test/data/sasl/sasl_report_file_h.core new file mode 100644 index 0000000..9e1cf08 --- /dev/null +++ b/test/data/sasl/sasl_report_file_h.core @@ -0,0 +1,198 @@ +module 'sasl_report_file_h' ['handle_call'/2, + 'handle_event'/2, + 'handle_info'/2, + 'init'/1, + 'module_info'/0, + 'module_info'/1, + 'terminate'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[115|[97|[115|[108|[95|[114|[101|[112|[111|[114|[116|[95|[102|[105|[108|[101|[95|[104|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]]]]]]],1}]] +'init'/1 = + %% Line 32 + fun (_0) -> + case _0 of + <{File,Modes0,Type}> + when call 'erlang':'is_list' + (Modes0) -> + do %% Line 33 + call 'erlang':'process_flag' + ('trap_exit', 'true') + let <_2> = + case %% Line 35 + call 'lists':'keymember' + ('encoding', 1, Modes0) of + %% Line 36 + <'true'> when 'true' -> + Modes0 + %% Line 37 + <'false'> when 'true' -> + [{'encoding','utf8'}|Modes0] + ( <_1> when 'true' -> + %% Line 35 + primop 'match_fail' + ({'case_clause',_1}) + -| ['compiler_generated'] ) + end + in let <_9> = + letrec + 'lc$^0'/1 = + %% Line 40 + fun (_6) -> + case _6 of + <[M|_5]> when 'true' -> + ( case call 'lists':'member' + (M, ['write'|['append'|['exclusive']]]) of + <'true'> when 'true' -> + let <_7> = + apply 'lc$^0'/1 + (_5) + in ( [M|_7] + -| ['compiler_generated'] ) + ( <'false'> when 'true' -> + apply 'lc$^0'/1 + (_5) + -| ['compiler_generated'] ) + ( <_8> when 'true' -> + primop 'match_fail' + ({'case_clause',_8}) + -| ['compiler_generated'] ) + end + -| ['list_comprehension'] ) + <[]> when 'true' -> + [] + ( <_16> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_16}) + -| [{'function_name',{'lc$^0',1}}] ) + -| ['compiler_generated'] ) + end + in %% Line 40 + apply 'lc$^0'/1 + (_2) + in let <_11> = + case _9 of + %% Line 41 + <[]> when 'true' -> + %% Line 42 + ['write'|_2] + %% Line 43 + <_15> when 'true' -> + _2 + end + in %% Line 46 + case call 'file':'open' + (File, _11) of + %% Line 47 + <{'ok',Fd}> when 'true' -> + %% Line 48 + {'ok',{Fd,File,Type}} + %% Line 49 + when 'true' -> + %% Line 50 + What + end + ( <_14> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_14}) + -| [{'function_name',{'init',1}}] ) + -| ['compiler_generated'] ) + end +'handle_event'/2 = + %% Line 53 + fun (_0,_1) -> + case <_0,_1> of + <{_X_Type,GL,_X_Msg},State> + when try + let <_3> = + call 'erlang':'node' + (GL) + in let <_2> = + call 'erlang':'node' + () + in call 'erlang':'/=' + (_3, _2) + of -> + Try + catch -> + 'false' -> + %% Line 54 + {'ok',State} + %% Line 55 + when 'true' -> + let <_4> = + apply %% Line 56 + 'tag_event'/1 + (%% Line 56 + Event) + in do %% Line 56 + ( call ( 'sasl_report' + -| ['result_not_wanted'] ):( 'write_report' + -| ['result_not_wanted'] ) + (Fd, Type, _4) + -| ['result_not_wanted'] ) + %% Line 57 + {'ok',_@r0} + %% Line 58 + <_8,State> when 'true' -> + %% Line 59 + {'ok',State} + end +'handle_info'/2 = + %% Line 61 + fun (_0,_1) -> + case <_0,_1> of + <{'EXIT',Fd,_X_Reason},{_4,_X_File,_X_Type}> + when call 'erlang':'=:=' + (_4, + Fd) -> + %% Line 62 + 'remove_handler' + %% Line 63 + <_5,State> when 'true' -> + %% Line 64 + {'ok',State} + end +'handle_call'/2 = + %% Line 66 + fun (_0,_1) -> + {'error','bad_query'} +'terminate'/2 = + %% Line 68 + fun (_0,_1) -> + case <_0,_1> of + <_5,{Fd,_X_File,_X_Type}> when 'true' -> + do %% Line 69 + ( call ( 'file' + -| ['result_not_wanted'] ):( 'close' + -| ['result_not_wanted'] ) + (Fd) + -| ['result_not_wanted'] ) + %% Line 70 + [] + ( <_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_4,_3}) + -| [{'function_name',{'terminate',2}}] ) + -| ['compiler_generated'] ) + end +'tag_event'/1 = + %% Line 72 + fun (_0) -> + let <_1> = + call %% Line 73 + 'calendar':%% Line 73 + 'local_time' + () + in %% Line 73 + {_1,_0} +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('sasl_report_file_h') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('sasl_report_file_h', _0) +end \ No newline at end of file diff --git a/test/data/sasl/sasl_report_tty_h.core b/test/data/sasl/sasl_report_tty_h.core new file mode 100644 index 0000000..123fb96 --- /dev/null +++ b/test/data/sasl/sasl_report_tty_h.core @@ -0,0 +1,91 @@ +module 'sasl_report_tty_h' ['handle_call'/2, + 'handle_event'/2, + 'handle_info'/2, + 'init'/1, + 'module_info'/0, + 'module_info'/1, + 'terminate'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[115|[97|[115|[108|[95|[114|[101|[112|[111|[114|[116|[95|[116|[116|[121|[95|[104|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]]]]]],1}]] +'init'/1 = + %% Line 32 + fun (_0) -> + %% Line 34 + {'ok',_0} +'handle_event'/2 = + %% Line 36 + fun (_0,_1) -> + case <_0,_1> of + <{Type,GL,_X_Msg},_8> + when let <_9> = + call 'erlang':'=:=' + (_8, Type) + in let <_10> = + try + let <_3> = + call 'erlang':'node' + (GL) + in let <_2> = + call 'erlang':'node' + () + in call 'erlang':'/=' + (_3, _2) + of -> + Try + catch -> + 'false' + in call 'erlang':'and' + (_9, _10) -> + %% Line 37 + {'ok',Type} + %% Line 38 + when 'true' -> + let <_4> = + apply %% Line 39 + 'tag_event'/1 + (%% Line 39 + Event) + in do %% Line 39 + ( call ( 'sasl_report' + -| ['result_not_wanted'] ):( 'write_report' + -| ['result_not_wanted'] ) + (( 'standard_io' + -| ['result_not_wanted'] ), Type, _4) + -| ['result_not_wanted'] ) + %% Line 40 + {'ok',Type} + end +'handle_info'/2 = + %% Line 42 + fun (_0,_1) -> + {'ok',_1} +'handle_call'/2 = + %% Line 44 + fun (_0,_1) -> + {'error','bad_query'} +'terminate'/2 = + %% Line 46 + fun (_0,_1) -> + %% Line 47 + [] +'tag_event'/1 = + %% Line 49 + fun (_0) -> + let <_1> = + call %% Line 50 + 'calendar':%% Line 50 + 'local_time' + () + in %% Line 50 + {_1,_0} +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('sasl_report_tty_h') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('sasl_report_tty_h', _0) +end \ No newline at end of file diff --git a/test/data/sasl/systools.core b/test/data/sasl/systools.core new file mode 100644 index 0000000..e6f6578 --- /dev/null +++ b/test/data/sasl/systools.core @@ -0,0 +1,195 @@ +module 'systools' ['compile_rel'/3, + 'make_relup'/3, + 'make_relup'/4, + 'make_script'/1, + 'make_script'/2, + 'make_tar'/1, + 'make_tar'/2, + 'module_info'/0, + 'module_info'/1, + 'script2boot'/1, + 'script2boot'/3] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[115|[121|[115|[116|[111|[111|[108|[115|[46|[101|[114|[108]]]]]]]]]]]]]]]],1}], + %% Line 1 + 'file' = + %% Line 1 + [{[47|[85|[115|[101|[114|[115|[47|[102|[101|[110|[103|[108|[101|[101|[47|[72|[97|[109|[108|[101|[114|[47|[111|[116|[112|[45|[79|[84|[80|[45|[50|[51|[46|[48|[45|[114|[99|[49|[47|[108|[105|[98|[47|[115|[97|[115|[108|[47|[46|[46|[47|[115|[116|[100|[108|[105|[98|[47|[105|[110|[99|[108|[117|[100|[101|[47|[101|[114|[108|[95|[99|[111|[109|[112|[105|[108|[101|[46|[104|[114|[108]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],1}], + %% Line 23 + 'record' = + %% Line 23 + [{'options',[{'typed_record_field',{'record_field',24,{'atom',24,'includes'},{'nil',24}},{'type',24,'list',[{'remote_type',24,[{'atom',24,'file'}|[{'atom',24,'filename'}|[[]]]]}]}}|[{'typed_record_field',{'record_field',26,{'atom',26,'outdir'},{'string',26,[46]}},{'remote_type',26,[{'atom',26,'file'}|[{'atom',26,'filename'}|[[]]]]}}|[{'typed_record_field',{'record_field',28,{'atom',28,'output_type'},{'atom',28,'undefined'}},{'type',28,'atom',[]}}|[{'typed_record_field',{'record_field',29,{'atom',29,'defines'},{'nil',29}},{'type',29,'list',[{'type',29,'union',[{'type',29,'atom',[]}|[{'type',29,'tuple',[{'type',29,'atom',[]}|[{'var',29,'_'}]]}]]}]}}|[{'typed_record_field',{'record_field',33,{'atom',33,'warning'},{'integer',33,1}},{'type',33,'non_neg_integer',[]}}|[{'typed_record_field',{'record_field',36,{'atom',36,'verbose'},{'atom',36,'false'}},{'type',36,'boolean',[]}}|[{'record_field',37,{'atom',37,'optimize'},{'integer',37,999}}|[{'typed_record_field',{'record_field',38,{'atom',38,'specific'},{'nil',38}},{'type',38,'list',[{'var',38,'_'}]}}|[{'typed_record_field',{'record_field',39,{'atom',39,'outfile'},{'string',39,[]}},{'remote_type',39,[{'atom',39,'file'}|[{'atom',39,'filename'}|[[]]]]}}|[{'typed_record_field',{'record_field',41,{'atom',41,'cwd'}},{'remote_type',41,[{'atom',41,'file'}|[{'atom',41,'filename'}|[[]]]]}}]]]]]]]]]]}], + %% Line 41 + 'file' = + %% Line 41 + [{[115|[114|[99|[47|[115|[121|[115|[116|[111|[111|[108|[115|[46|[101|[114|[108]]]]]]]]]]]]]]]],41}]] +'make_script'/1 = + %% Line 50 + fun (_0) -> + case _0 of + <[RelName|Opts]> + when call 'erlang':'is_atom' + (RelName) -> + %% Line 51 + apply 'make_script'/2 + ([RelName|[]], Opts) + %% Line 52 + when 'true' -> + apply 'make_script'/2 + (RelName, []) + end +'make_script'/2 = + %% Line 54 + fun (_0,_1) -> + %% Line 55 + call 'systools_make':'make_script' + (_0, _1) +'make_tar'/1 = + %% Line 65 + fun (_0) -> + apply 'make_tar'/2 + (_0, []) +'make_tar'/2 = + %% Line 67 + fun (_0,_1) -> + %% Line 68 + call 'systools_make':'make_tar' + (_0, _1) +'script2boot'/1 = + %% Line 73 + fun (_0) -> + let <_2> = + call %% Line 74 + 'erlang':%% Line 74 + '++' + (_0, %% Line 74 + [46|[115|[99|[114|[105|[112|[116]]]]]]]) + in let <_1> = + call %% Line 74 + 'erlang':%% Line 74 + '++' + (_0, %% Line 74 + [46|[98|[111|[111|[116]]]]]) + in %% Line 74 + case call 'systools_lib':'file_term2binary' + (_2, _1) of + %% Line 75 + <{'error',Error}> when 'true' -> + let <_3> = + call %% Line 76 + 'systools_make':%% Line 76 + 'format_error' + (%% Line 76 + Error) + in do %% Line 76 + call 'io':'format' + ([126|[116|[115]]], [_3|[]]) + %% Line 77 + 'error' + %% Line 78 + <_6> when 'true' -> + %% Line 79 + 'ok' + end +'script2boot'/3 = + %% Line 82 + fun (_0,_1,_2) -> + let = + call %% Line 83 + 'erlang':%% Line 83 + '++' + (_0, %% Line 83 + [46|[115|[99|[114|[105|[112|[116]]]]]]]) + in let = + call %% Line 84 + 'erlang':%% Line 84 + '++' + (_1, %% Line 84 + [46|[98|[111|[111|[116]]]]]) + in %% Line 85 + case call 'systools_lib':'file_term2binary' + (Input, Output) of + %% Line 86 + <{'error',Error}> when 'true' -> + let <_5> = + call %% Line 87 + 'systools_make':%% Line 87 + 'format_error' + (%% Line 87 + Error) + in do %% Line 87 + call 'io':'format' + ([126|[116|[115]]], [_5|[]]) + %% Line 88 + 'error' + %% Line 89 + <_10> when 'true' -> + %% Line 90 + 'ok' + end +'make_relup'/3 = + %% Line 98 + fun (_0,_1,_2) -> + %% Line 99 + call 'systools_relup':'mk_relup' + (_0, _1, _2, []) +'make_relup'/4 = + %% Line 100 + fun (_0,_1,_2,_3) -> + %% Line 101 + call 'systools_relup':'mk_relup' + (_0, _1, _2, _3) +'compile_rel'/3 = + %% Line 106 + fun (_0,_1,_2) -> + let <_3> = + apply %% Line 107 + 'translate_options'/1 + (_2) + in %% Line 107 + call 'systools_make':'make_script' + (_0, _1, _3) +'translate_options'/1 = + %% Line 109 + fun (_0) -> + %% Line 110 + ( case _0 of + ( <( {'options',_rec0,_6,_7,_8,_9,_10,_11,_12,_13,_14} + -| ['compiler_generated'] )> when 'true' -> + ( case _0 of + ( <( {'options',_16,_17,_18,_19,_20,_21,_22,_rec1,_23,_24} + -| ['compiler_generated'] )> when 'true' -> + [{'path',_rec0}|_rec1] + -| ['compiler_generated'] ) + ( <_25> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','options'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + ( <_15> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {'badrecord','options'} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('systools') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('systools', _0) +end \ No newline at end of file diff --git a/test/data/sasl/systools_lib.core b/test/data/sasl/systools_lib.core new file mode 100644 index 0000000..82b6e60 --- /dev/null +++ b/test/data/sasl/systools_lib.core @@ -0,0 +1,565 @@ +module 'systools_lib' ['file_term2binary'/2, + 'get_dirs'/1, + 'get_path'/1, + 'module_info'/0, + 'module_info'/1, + 'read_term'/1, + 'read_term_from_stream'/2, + 'werror'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[115|[121|[115|[116|[111|[111|[108|[115|[95|[108|[105|[98|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]],1}], + %% Line 1 + 'file' = + %% Line 1 + [{[47|[117|[115|[114|[47|[108|[111|[99|[97|[108|[47|[67|[101|[108|[108|[97|[114|[47|[101|[114|[108|[97|[110|[103|[47|[50|[50|[46|[50|[47|[108|[105|[98|[47|[101|[114|[108|[97|[110|[103|[47|[108|[105|[98|[47|[107|[101|[114|[110|[101|[108|[45|[54|[46|[53|[46|[49|[47|[105|[110|[99|[108|[117|[100|[101|[47|[102|[105|[108|[101|[46|[104|[114|[108]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],1}], + %% Line 25 + 'record' = + %% Line 25 + [{'file_info',[{'typed_record_field',{'record_field',26,{'atom',26,'size'}},{'type',26,'union',[{'type',26,'non_neg_integer',[]}|[{'atom',26,'undefined'}]]}}|[{'typed_record_field',{'record_field',27,{'atom',27,'type'}},{'type',27,'union',[{'atom',27,'device'}|[{'atom',27,'directory'}|[{'atom',27,'other'}|[{'atom',27,'regular'}|[{'atom',27,'symlink'}|[{'atom',28,'undefined'}]]]]]]}}|[{'typed_record_field',{'record_field',29,{'atom',29,'access'}},{'type',29,'union',[{'atom',29,'read'}|[{'atom',29,'write'}|[{'atom',29,'read_write'}|[{'atom',29,'none'}|[{'atom',29,'undefined'}]]]]]}}|[{'typed_record_field',{'record_field',30,{'atom',30,'atime'}},{'type',30,'union',[{'remote_type',30,[{'atom',30,'file'}|[{'atom',30,'date_time'}|[[]]]]}|[{'type',30,'non_neg_integer',[]}|[{'atom',30,'undefined'}]]]}}|[{'typed_record_field',{'record_field',34,{'atom',34,'mtime'}},{'type',34,'union',[{'remote_type',34,[{'atom',34,'file'}|[{'atom',34,'date_time'}|[[]]]]}|[{'type',34,'non_neg_integer',[]}|[{'atom',34,'undefined'}]]]}}|[{'typed_record_field',{'record_field',36,{'atom',36,'ctime'}},{'type',36,'union',[{'remote_type',36,[{'atom',36,'file'}|[{'atom',36,'date_time'}|[[]]]]}|[{'type',36,'non_neg_integer',[]}|[{'atom',36,'undefined'}]]]}}|[{'typed_record_field',{'record_field',42,{'atom',42,'mode'}},{'type',42,'union',[{'type',42,'non_neg_integer',[]}|[{'atom',42,'undefined'}]]}}|[{'typed_record_field',{'record_field',46,{'atom',46,'links'}},{'type',46,'union',[{'type',46,'non_neg_integer',[]}|[{'atom',46,'undefined'}]]}}|[{'typed_record_field',{'record_field',49,{'atom',49,'major_device'}},{'type',49,'union',[{'type',49,'non_neg_integer',[]}|[{'atom',49,'undefined'}]]}}|[{'typed_record_field',{'record_field',55,{'atom',55,'minor_device'}},{'type',55,'union',[{'type',55,'non_neg_integer',[]}|[{'atom',55,'undefined'}]]}}|[{'typed_record_field',{'record_field',57,{'atom',57,'inode'}},{'type',57,'union',[{'type',57,'non_neg_integer',[]}|[{'atom',57,'undefined'}]]}}|[{'typed_record_field',{'record_field',58,{'atom',58,'uid'}},{'type',58,'union',[{'type',58,'non_neg_integer',[]}|[{'atom',58,'undefined'}]]}}|[{'typed_record_field',{'record_field',59,{'atom',59,'gid'}},{'type',59,'union',[{'type',59,'non_neg_integer',[]}|[{'atom',59,'undefined'}]]}}]]]]]]]]]]]]]}], + %% Line 62 + 'record' = + %% Line 62 + [{'file_descriptor',[{'typed_record_field',{'record_field',63,{'atom',63,'module'}},{'type',63,'module',[]}}|[{'typed_record_field',{'record_field',64,{'atom',64,'data'}},{'type',64,'term',[]}}]]}], + %% Line 31 + 'file' = + %% Line 31 + [{[115|[114|[99|[47|[115|[121|[115|[116|[111|[111|[108|[115|[95|[108|[105|[98|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]],31}]] +'file_term2binary'/2 = + %% Line 35 + fun (_0,_1) -> + %% Line 36 + case apply 'read_term'/1 + (_0) of + %% Line 37 + <{'ok',Term}> when 'true' -> + let <_2> = + call %% Line 38 + 'erlang':%% Line 38 + 'term_to_binary' + (%% Line 38 + Term) + in %% Line 38 + case call 'file':'write_file' + (_1, _2) of + %% Line 39 + <'ok'> when 'true' -> + 'ok' + %% Line 40 + <{'error',Error}> when 'true' -> + {'error',{'open',_1,Error}} + ( <_3> when 'true' -> + primop 'match_fail' + ({'case_clause',_3}) + -| ['compiler_generated'] ) + end + %% Line 42 + when 'true' -> + %% Line 43 + Other + end +'read_term'/1 = + %% Line 53 + fun (_0) -> + %% Line 54 + case call 'file':'open' + (_0, ['read']) of + %% Line 55 + <{'ok',Stream}> when 'true' -> + let = + apply %% Line 56 + 'read_term_from_stream'/2 + (%% Line 56 + Stream, _0) + in %% Line 57 + case call 'file':'close' + (Stream) of + %% Line 58 + <'ok'> when 'true' -> + Res + %% Line 59 + <{'error',Error}> when 'true' -> + {'error',{'close',_0,Error}} + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end + %% Line 61 + <{'error',Error}> when 'true' -> + %% Line 62 + {'error',{'open',_0,Error}} + ( <_3> when 'true' -> + primop 'match_fail' + ({'case_clause',_3}) + -| ['compiler_generated'] ) + end +'read_term_from_stream'/2 = + %% Line 65 + fun (_0,_1) -> + let = + call %% Line 66 + 'epp':%% Line 66 + 'set_encoding' + (_0) + in %% Line 68 + case call 'io':'request' + (_0, {'get_until',Encoding,'','erl_scan','tokens',[1]}) of + %% Line 69 + <{'ok',Toks,_X_EndLine}> when 'true' -> + %% Line 70 + case call 'erl_parse':'parse_term' + (Toks) of + %% Line 71 + <_@r0 = {'ok',Term}> when 'true' -> + %% Line 72 + _@r0 + %% Line 73 + <{'error',Error}> when 'true' -> + %% Line 74 + {'error',{'parse',_1,Error}} + ( <_4> when 'true' -> + primop 'match_fail' + ({'case_clause',_4}) + -| ['compiler_generated'] ) + end + %% Line 76 + <{'error',_X_E,_X_EndLine}> when 'true' -> + %% Line 77 + {'error',{'read',_1}} + %% Line 78 + <{'eof',_X_EndLine}> when 'true' -> + %% Line 79 + {'error',{'read',_1}} + ( <_5> when 'true' -> + primop 'match_fail' + ({'case_clause',_5}) + -| ['compiler_generated'] ) + end +'get_dirs'/1 = + %% Line 95 + fun (_0) -> + case _0 of + + when call 'erlang':'is_list' + (_0) -> + let = + call %% Line 96 + 'filename':%% Line 96 + 'split' + (%% Line 96 + RegPath) + in let = + apply %% Line 97 + 'expand_names'/1 + (%% Line 97 + Names) + in catch + %% Line 98 + apply 'get_dirs'/3 + (ExpNames, [], 'true') + %% Line 99 + <_4> when 'true' -> + %% Line 100 + {'error','badarg'} + end +'get_path'/1 = + %% Line 102 + fun (_0) -> + case _0 of + + when call 'erlang':'is_list' + (_0) -> + let = + fun (_2) -> + %% Line 104 + case apply 'get_dirs'/1 + (_2) of + %% Line 105 + <{'ok',Dirs}> when 'true' -> + {'true',Dirs} + %% Line 106 + <_7> when 'true' -> + 'false' + end + in let <_5> = + call %% Line 109 + 'lists':%% Line 109 + 'zf' + (%% Line 109 + F, %% Line 109 + RegPath) + in %% Line 109 + apply 'flat'/2 + (_5, []) + %% Line 110 + <_8> when 'true' -> + %% Line 111 + [] + end +'expand_names'/1 = + %% Line 122 + fun (_0) -> + let <_5> = + fun (_3) -> + %% Line 123 + case _3 of + <[42]> when 'true' -> + %% Line 124 + {'true',[91|[94|[47|[93|[43]]]]]} + %% Line 125 + when 'true' -> + %% Line 126 + case call 'lists':'member' + (42, N) of + %% Line 127 + <'true'> when 'true' -> + let <_1> = + apply 'expand'/2 + (N, []) + in {'true',_1} + %% Line 128 + <_7> when 'true' -> + {'false',N} + end + end + in %% Line 123 + call 'lists':'map' + (_5, _0) +'expand'/2 = + %% Line 132 + fun (_0,_1) -> + case <_0,_1> of + <[42|T],Ack> when 'true' -> + let <_2> = + call %% Line 133 + 'erlang':%% Line 133 + '++' + (%% Line 133 + [42|[93|[47|[94|[91]]]]], %% Line 133 + Ack) + in %% Line 133 + apply 'expand'/2 + (T, _2) + %% Line 134 + <[H|T],Ack> when 'true' -> + %% Line 135 + apply 'expand'/2 + (T, [H|Ack]) + %% Line 136 + <[],Ack> when 'true' -> + %% Line 137 + call 'lists':'reverse' + (Ack) + ( <_4,_3> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_4,_3}) + -| [{'function_name',{'expand',2}}] ) + -| ['compiler_generated'] ) + end +'get_dirs'/3 = + %% Line 147 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <[{'false',Name}|T],F,Root> when 'true' -> + let <_3> = + apply %% Line 148 + 'add_dir'/3 + (%% Line 148 + Name, %% Line 148 + F, %% Line 148 + Root) + in %% Line 148 + apply 'get_dirs'/3 + (T, _3, 'false') + %% Line 149 + <[{'true',RegName}|T],F,Root> when 'true' -> + let <_4> = + apply %% Line 150 + 'add_dirs'/3 + (%% Line 150 + RegName, %% Line 150 + F, %% Line 150 + Root) + in %% Line 150 + apply 'get_dirs'/3 + (T, _4, 'false') + %% Line 151 + <[],F,_8> when 'true' -> + %% Line 152 + {'ok',F} + ( <_7,_6,_5> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_7,_6,_5}) + -| [{'function_name',{'get_dirs',3}}] ) + -| ['compiler_generated'] ) + end +'add_dir'/3 = + %% Line 154 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 155 + case apply 'dir_p'/1 + (Name) of + %% Line 156 + <'true'> when 'true' -> + [Name|[]] + %% Line 157 + <_12> when 'true' -> + [] + end + %% Line 159 + when 'true' -> + let <_8> = + fun (_6) -> + let = + call %% Line 161 + 'filename':%% Line 161 + 'join' + (%% Line 160 + _6, %% Line 161 + Name) + in %% Line 162 + case apply 'dir_p'/1 + (D) of + %% Line 163 + <'true'> when 'true' -> + {'true',D} + %% Line 164 + <_13> when 'true' -> + 'false' + end + in %% Line 160 + call 'lists':'zf' + (_8, %% Line 166 + Dirs) + end +'add_dirs'/3 = + %% Line 168 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + when 'true' -> + %% Line 169 + case apply 'regexp_match'/3 + (RegName, [46], 'true') of + %% Line 170 + <{'true',AddDirs}> when 'true' -> + AddDirs + %% Line 171 + <_11> when 'true' -> + [] + end + %% Line 173 + when 'true' -> + let = + fun (_4) -> + %% Line 175 + apply 'regexp_match'/3 + (RegName, _4, Root) + in let <_7> = + call %% Line 177 + 'lists':%% Line 177 + 'zf' + (%% Line 177 + Fun, %% Line 177 + Dirs) + in %% Line 177 + apply 'flat'/2 + (_7, []) + end +'regexp_match'/3 = + %% Line 186 + fun (_0,_1,_2) -> + %% Line 187 + case call 'file':'list_dir' + (_1) of + %% Line 188 + <{'ok',Files}> + when try + let <_3> = + call 'erlang':'length' + (Files) + in call 'erlang':'>' + (_3, 0) + of -> + Try + catch -> + 'false' -> + %% Line 189 + case call 're':'compile' + (_0, ['unicode']) of + %% Line 190 + <{'ok',MP}> when 'true' -> + let = + fun (_7) -> + %% Line 192 + case call 're':'run' + (_7, MP, [{'capture','first','list'}]) of + %% Line 193 + <{'match',[_16|[]]}> + when call 'erlang':'=:=' + (_16, + _7) -> + let = + apply %% Line 194 + 'join'/3 + (_1, _7, _2) + in %% Line 195 + case apply 'dir_p'/1 + (DirF) of + %% Line 196 + <'true'> when 'true' -> + %% Line 197 + {'true',DirF} + %% Line 198 + <_17> when 'true' -> + %% Line 199 + 'false' + end + %% Line 201 + <_18> when 'true' -> + %% Line 202 + 'false' + end + in let <_10> = + call %% Line 205 + 'lists':%% Line 205 + 'zf' + (%% Line 205 + FR, %% Line 205 + Files) + in %% Line 205 + {'true',_10} + %% Line 206 + <_19> when 'true' -> + %% Line 207 + 'false' + end + %% Line 209 + <_20> when 'true' -> + %% Line 210 + 'false' + end +'join'/3 = + %% Line 214 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <_6,F,'true'> when 'true' -> + F + %% Line 215 + when 'true' -> + call 'filename':'join' + (Dir, F) + end +'dir_p'/1 = + %% Line 217 + fun (_0) -> + %% Line 218 + case call 'file':'read_file_info' + (_0) of + %% Line 219 + <{'ok',Info = {'file_info',_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21}}> + when ( try + let <_5> = + call 'erlang':'element' + (3, Info) + in call 'erlang':'=:=' + (_5, 'directory') + of -> + Try + catch -> + 'false' + -| ['compiler_generated'] ) -> + 'true' + %% Line 220 + <_22> when 'true' -> + 'false' + end +'flat'/2 = + %% Line 224 + fun (_0,_1) -> + case <_0,_1> of + <[H|T],Ack> + when try + let <_2> = + call 'erlang':'hd' + (H) + in call 'erlang':'is_list' + (_2) + of -> + Try + catch -> + 'false' -> + let <_3> = + call %% Line 225 + 'lists':%% Line 225 + 'reverse' + (%% Line 225 + H) + in let <_4> = + call %% Line 225 + 'erlang':%% Line 225 + '++' + (_3, %% Line 225 + Ack) + in %% Line 225 + apply 'flat'/2 + (T, _4) + %% Line 226 + <[[]|T],Ack> when 'true' -> + %% Line 227 + apply 'flat'/2 + (T, Ack) + %% Line 228 + <[H|T],Ack> when 'true' -> + %% Line 229 + apply 'flat'/2 + (T, [H|Ack]) + %% Line 230 + <[],Ack> when 'true' -> + %% Line 231 + call 'lists':'reverse' + (Ack) + ( <_6,_5> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_6,_5}) + -| [{'function_name',{'flat',2}}] ) + -| ['compiler_generated'] ) + end +'werror'/2 = + %% Line 233 + fun (_0,_1) -> + %% Line 234 + ( case call 'lists':'member' + ('warnings_as_errors', _0) of + ( <( 'true' + -| ['compiler_generated'] )> when 'true' -> + call 'erlang':'=/=' + (_1, []) + -| ['compiler_generated'] ) + ( <( 'false' + -| ['compiler_generated'] )> when 'true' -> + 'false' + -| ['compiler_generated'] ) + ( <_2> when 'true' -> + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {( 'badarg' + -| ['compiler_generated'] ),_2} + -| ['compiler_generated'] )) + -| ['compiler_generated'] ) + -| ['compiler_generated'] ) + end + -| ['compiler_generated'] ) +'module_info'/0 = + fun () -> + call 'erlang':'get_module_info' + ('systools_lib') +'module_info'/1 = + fun (_0) -> + call 'erlang':'get_module_info' + ('systools_lib', _0) +end \ No newline at end of file diff --git a/test/data/sasl/systools_make.core b/test/data/sasl/systools_make.core new file mode 100644 index 0000000..a5c43b3 --- /dev/null +++ b/test/data/sasl/systools_make.core @@ -0,0 +1,8077 @@ +module 'systools_make' ['format_error'/1, + 'format_warning'/1, + 'get_release'/2, + 'get_release'/3, + 'get_release'/4, + 'make_hybrid_boot'/4, + 'make_script'/1, + 'make_script'/2, + 'make_script'/3, + 'make_tar'/1, + 'make_tar'/2, + 'module_info'/0, + 'module_info'/1, + 'pack_app'/1, + 'preloaded'/0, + 'read_application'/4, + 'read_release'/2] + attributes [%% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[115|[121|[115|[116|[111|[111|[108|[115|[95|[109|[97|[107|[101|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]],1}], + %% Line 1 + 'file' = + %% Line 1 + [{[115|[114|[99|[47|[115|[121|[115|[116|[111|[111|[108|[115|[46|[104|[114|[108]]]]]]]]]]]]]]]],1}], + %% Line 27 + 'record' = + %% Line 27 + [{'release',[{'record_field',29,{'atom',29,'name'}}|[{'record_field',30,{'atom',30,'vsn'}}|[{'record_field',31,{'atom',31,'erts_vsn'}}|[{'record_field',32,{'atom',32,'applications'}}|[{'record_field',35,{'atom',35,'incl_apps'}}]]]]]}], + %% Line 40 + 'record' = + %% Line 40 + [{'application',[{'record_field',41,{'atom',41,'name'}}|[{'record_field',42,{'atom',42,'type'},{'atom',42,'permanent'}}|[{'record_field',43,{'atom',43,'vsn'},{'string',43,[]}}|[{'record_field',44,{'atom',44,'id'},{'string',44,[]}}|[{'record_field',45,{'atom',45,'description'},{'string',45,[]}}|[{'record_field',46,{'atom',46,'modules'},{'nil',46}}|[{'record_field',49,{'atom',49,'uses'},{'nil',49}}|[{'record_field',51,{'atom',51,'includes'},{'nil',51}}|[{'record_field',53,{'atom',53,'regs'},{'nil',53}}|[{'record_field',56,{'atom',56,'env'},{'nil',56}}|[{'record_field',58,{'atom',58,'maxT'},{'atom',58,'infinity'}}|[{'record_field',60,{'atom',60,'maxP'},{'atom',60,'infinity'}}|[{'record_field',62,{'atom',62,'mod'},{'nil',62}}|[{'record_field',64,{'atom',64,'start_phases'}}|[{'record_field',67,{'atom',67,'dir'},{'string',67,[]}}]]]]]]]]]]]]]]]}], + %% Line 42 + 'file' = + %% Line 42 + [{[115|[114|[99|[47|[115|[121|[115|[116|[111|[111|[108|[115|[95|[109|[97|[107|[101|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]],42}], + %% Line 1 + 'file' = + %% Line 1 + [{[47|[117|[115|[114|[47|[108|[111|[99|[97|[108|[47|[67|[101|[108|[108|[97|[114|[47|[101|[114|[108|[97|[110|[103|[47|[50|[50|[46|[50|[47|[108|[105|[98|[47|[101|[114|[108|[97|[110|[103|[47|[108|[105|[98|[47|[107|[101|[114|[110|[101|[108|[45|[54|[46|[53|[46|[49|[47|[105|[110|[99|[108|[117|[100|[101|[47|[102|[105|[108|[101|[46|[104|[114|[108]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],1}], + %% Line 25 + 'record' = + %% Line 25 + [{'file_info',[{'typed_record_field',{'record_field',26,{'atom',26,'size'}},{'type',26,'union',[{'type',26,'non_neg_integer',[]}|[{'atom',26,'undefined'}]]}}|[{'typed_record_field',{'record_field',27,{'atom',27,'type'}},{'type',27,'union',[{'atom',27,'device'}|[{'atom',27,'directory'}|[{'atom',27,'other'}|[{'atom',27,'regular'}|[{'atom',27,'symlink'}|[{'atom',28,'undefined'}]]]]]]}}|[{'typed_record_field',{'record_field',29,{'atom',29,'access'}},{'type',29,'union',[{'atom',29,'read'}|[{'atom',29,'write'}|[{'atom',29,'read_write'}|[{'atom',29,'none'}|[{'atom',29,'undefined'}]]]]]}}|[{'typed_record_field',{'record_field',30,{'atom',30,'atime'}},{'type',30,'union',[{'remote_type',30,[{'atom',30,'file'}|[{'atom',30,'date_time'}|[[]]]]}|[{'type',30,'non_neg_integer',[]}|[{'atom',30,'undefined'}]]]}}|[{'typed_record_field',{'record_field',34,{'atom',34,'mtime'}},{'type',34,'union',[{'remote_type',34,[{'atom',34,'file'}|[{'atom',34,'date_time'}|[[]]]]}|[{'type',34,'non_neg_integer',[]}|[{'atom',34,'undefined'}]]]}}|[{'typed_record_field',{'record_field',36,{'atom',36,'ctime'}},{'type',36,'union',[{'remote_type',36,[{'atom',36,'file'}|[{'atom',36,'date_time'}|[[]]]]}|[{'type',36,'non_neg_integer',[]}|[{'atom',36,'undefined'}]]]}}|[{'typed_record_field',{'record_field',42,{'atom',42,'mode'}},{'type',42,'union',[{'type',42,'non_neg_integer',[]}|[{'atom',42,'undefined'}]]}}|[{'typed_record_field',{'record_field',46,{'atom',46,'links'}},{'type',46,'union',[{'type',46,'non_neg_integer',[]}|[{'atom',46,'undefined'}]]}}|[{'typed_record_field',{'record_field',49,{'atom',49,'major_device'}},{'type',49,'union',[{'type',49,'non_neg_integer',[]}|[{'atom',49,'undefined'}]]}}|[{'typed_record_field',{'record_field',55,{'atom',55,'minor_device'}},{'type',55,'union',[{'type',55,'non_neg_integer',[]}|[{'atom',55,'undefined'}]]}}|[{'typed_record_field',{'record_field',57,{'atom',57,'inode'}},{'type',57,'union',[{'type',57,'non_neg_integer',[]}|[{'atom',57,'undefined'}]]}}|[{'typed_record_field',{'record_field',58,{'atom',58,'uid'}},{'type',58,'union',[{'type',58,'non_neg_integer',[]}|[{'atom',58,'undefined'}]]}}|[{'typed_record_field',{'record_field',59,{'atom',59,'gid'}},{'type',59,'union',[{'type',59,'non_neg_integer',[]}|[{'atom',59,'undefined'}]]}}]]]]]]]]]]]]]}], + %% Line 62 + 'record' = + %% Line 62 + [{'file_descriptor',[{'typed_record_field',{'record_field',63,{'atom',63,'module'}},{'type',63,'module',[]}}|[{'typed_record_field',{'record_field',64,{'atom',64,'data'}},{'type',64,'term',[]}}]]}], + %% Line 44 + 'file' = + %% Line 44 + [{[115|[114|[99|[47|[115|[121|[115|[116|[111|[111|[108|[115|[95|[109|[97|[107|[101|[46|[101|[114|[108]]]]]]]]]]]]]]]]]]]]],44}], + %% Line 47 + 'compile' = + %% Line 47 + [{'inline',[{'badarg',2}]}]] +'make_script'/1 = + %% Line 75 + fun (_0) -> + case _0 of + + when call 'erlang':'is_list' + (_0) -> + %% Line 76 + apply 'make_script'/2 + (RelName, []) + %% Line 77 + when 'true' -> + let <_1> = + [%% Line 78 + RelName|%% Line 78 + ( [] + -| ['compiler_generated'] )] + in %% Line 139 + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {( 'badarg' + -| ['compiler_generated'] ),RelName} + -| ['compiler_generated'] ), _1) + -| ['compiler_generated'] ) + end +'make_script'/2 = + %% Line 80 + fun (_0,_1) -> + case <_0,_1> of + + when let <_2> = + call 'erlang':'is_list' + (RelName) + in let <_3> = + call 'erlang':'is_list' + (Flags) + in call 'erlang':'and' + (_2, _3) -> + %% Line 81 + case apply 'get_outdir'/1 + (Flags) of + %% Line 82 + <[]> when 'true' -> + %% Line 83 + apply 'make_script'/3 + (RelName, RelName, Flags) + %% Line 84 + when 'true' -> + let <_4> = + call %% Line 89 + 'filename':%% Line 89 + 'basename' + (%% Line 89 + RelName) + in let = + call %% Line 89 + 'filename':%% Line 89 + 'join' + (%% Line 89 + OutDir, _4) + in %% Line 90 + apply 'make_script'/3 + (RelName, Output, Flags) + end + ( <_8,_7> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_8,_7}) + -| [{'function_name',{'make_script',2}}] ) + -| ['compiler_generated'] ) + end +'make_script'/3 = + %% Line 93 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + + when try + let <_3> = + call 'erlang':'is_list' + (RelName) + in let <_4> = + call %% Line 94 + 'erlang':%% Line 94 + 'is_list' + (%% Line 94 + Output) + in let <_5> = + call %% Line 95 + 'erlang':%% Line 95 + 'is_list' + (%% Line 95 + Flags) + in let <_6> = + call 'erlang':'and' + (_4, _5) + in call 'erlang':'and' + (_3, _6) + of -> + Try + catch -> + 'false' -> + %% Line 96 + case apply 'check_args_script'/1 + (Flags) of + %% Line 97 + <[]> when 'true' -> + let = + apply %% Line 98 + 'get_path'/1 + (%% Line 98 + Flags) + in let = + apply %% Line 99 + 'mk_path'/1 + (%% Line 99 + Path0) + in let <_9> = + call %% Line 100 + 'code':%% Line 100 + 'get_path' + () + in let <_10> = + call %% Line 100 + 'erlang':%% Line 100 + '++' + (%% Line 100 + Path1, _9) + in let = + apply %% Line 100 + 'make_set'/1 + (_10) + in let <_13> = + call %% Line 101 + 'lists':%% Line 101 + 'member' + (%% Line 101 + 'src_tests', %% Line 101 + Flags) + in let <_12> = + apply %% Line 101 + 'xref_p'/1 + (%% Line 101 + Flags) + in let = {_13,_12} + in let <_15> = + apply %% Line 102 + 'machine'/1 + (%% Line 102 + Flags) + in %% Line 102 + case apply 'get_release'/4 + (RelName, Path, ModTestP, _15) of + %% Line 103 + <{'ok',Release,Appls,Warnings0}> when 'true' -> + let = + apply %% Line 104 + 'wsasl'/2 + (%% Line 104 + Flags, %% Line 104 + Warnings0) + in %% Line 105 + case call 'systools_lib':'werror' + (Flags, Warnings) of + %% Line 106 + <'true'> when 'true' -> + let <_21> = + letrec + 'lc$^0'/1 = + %% Line 107 + fun (_19) -> + case _19 of + <[{'warning',W}|_18]> when 'true' -> + let <_20> = + apply 'lc$^0'/1 + (_18) + in ( [W|_20] + -| ['compiler_generated'] ) + ( <[_17|_18]> when 'true' -> + apply 'lc$^0'/1 + (_18) + -| ['compiler_generated'] ) + <[]> when 'true' -> + [] + ( <_30> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_30}) + -| [{'function_name',{'lc$^0',1}}] ) + -| ['compiler_generated'] ) + end + in %% Line 107 + apply 'lc$^0'/1 + (Warnings) + in %% Line 108 + apply 'return'/3 + ({'error','systools_make',%% Line 109 + {'warnings_treated_as_errors',_21}}, %% Line 110 + Warnings, %% Line 111 + Flags) + %% Line 112 + <'false'> when 'true' -> + %% Line 113 + case apply 'generate_script'/4 + (Output, Release, Appls, Flags) of + %% Line 114 + <'ok'> when 'true' -> + %% Line 115 + apply 'return'/3 + ('ok', Warnings, Flags) + %% Line 116 + when 'true' -> + %% Line 117 + apply 'return'/3 + (Error, Warnings, Flags) + end + ( <_24> when 'true' -> + primop 'match_fail' + ({'case_clause',_24}) + -| ['compiler_generated'] ) + end + %% Line 120 + when 'true' -> + %% Line 121 + apply 'return'/3 + (Error, [], Flags) + end + %% Line 123 + when 'true' -> + let <_32> = + [%% Line 124 + RelName|%% Line 124 + ( [Flags|( [] + -| ['compiler_generated'] )] + -| ['compiler_generated'] )] + in %% Line 139 + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {( 'badarg' + -| ['compiler_generated'] ),ErrorVars} + -| ['compiler_generated'] ), _32) + -| ['compiler_generated'] ) + end + %% Line 127 + + when call 'erlang':'is_list' + (Flags) -> + let <_36> = + [%% Line 128 + RelName|%% Line 128 + ( [Flags|( [] + -| ['compiler_generated'] )] + -| ['compiler_generated'] )] + in %% Line 139 + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {( 'badarg' + -| ['compiler_generated'] ),RelName} + -| ['compiler_generated'] ), _36) + -| ['compiler_generated'] ) + %% Line 129 + when 'true' -> + let <_40> = + [%% Line 130 + RelName|%% Line 130 + ( [Flags|( [] + -| ['compiler_generated'] )] + -| ['compiler_generated'] )] + in %% Line 139 + ( call ( 'erlang' + -| ['compiler_generated'] ):( 'error' + -| ['compiler_generated'] ) + (( {( 'badarg' + -| ['compiler_generated'] ),Flags} + -| ['compiler_generated'] ), _40) + -| ['compiler_generated'] ) + end +'wsasl'/2 = + %% Line 132 + fun (_0,_1) -> + %% Line 133 + case call 'lists':'member' + ('no_warn_sasl', _0) of + %% Line 134 + <'true'> when 'true' -> + call 'lists':'delete' + ({'warning','missing_sasl'}, _1) + %% Line 135 + <'false'> when 'true' -> + _1 + ( <_2> when 'true' -> + primop 'match_fail' + ({'case_clause',_2}) + -| ['compiler_generated'] ) + end +'badarg'/2 = + %% Line 138 + fun (_0,_1) -> + %% Line 139 + call 'erlang':'error' + ({'badarg',_0}, _1) +'machine'/1 = + %% Line 141 + fun (_0) -> + %% Line 142 + case apply 'get_flag'/2 + ('machine', _0) of + %% Line 143 + <{'machine',Machine}> + when call 'erlang':'is_atom' + (Machine) -> + Machine + %% Line 144 + <_3> when 'true' -> + 'false' + end +'get_path'/1 = + %% Line 147 + fun (_0) -> + %% Line 148 + case apply 'get_flag'/2 + ('path', _0) of + %% Line 149 + <{'path',Path}> + when call 'erlang':'is_list' + (Path) -> + Path + %% Line 150 + <_3> when 'true' -> + [] + end +'get_outdir'/1 = + %% Line 153 + fun (_0) -> + %% Line 154 + case apply 'get_flag'/2 + ('outdir', _0) of + %% Line 155 + <{'outdir',OutDir}> + when call 'erlang':'is_list' + (OutDir) -> + %% Line 156 + OutDir + %% Line 157 + <_3> when 'true' -> + %% Line 158 + [] + end +'return'/3 = + %% Line 161 + fun (_0,_1,_2) -> + case <_0,_1,_2> of + <'ok',Warnings,Flags> when 'true' -> + %% Line 162 + case call 'lists':'member' + ('silent', Flags) of + %% Line 163 + <'true'> when 'true' -> + %% Line 164 + {'ok','systools_make',Warnings} + %% Line 165 + <_10> when 'true' -> + let <_3> = + apply %% Line 166 + 'format_warning'/1 + (%% Line 166 + Warnings) + in do %% Line 166 + call 'io':'format' + ([126|[116|[115]]], [_3|[]]) + %% Line 167 + 'ok' + end + %% Line 169 + <_@r0 = {'error',Mod,Error},_11,Flags> when 'true' -> + %% Line 170 + case call 'lists':'member' + ('silent', Flags) of + %% Line 171 + <'true'> when 'true' -> + %% Line 172 + _@r0 + %% Line 173 + <_12> when 'true' -> + let <_5> = + call %% Line 174 + Mod:%% Line 174 + 'format_error' + (%% Line 174 + Error) + in do %% Line 174 + call 'io':'format' + ([126|[116|[115]]], [_5|[]]) + %% Line 175 + 'error' + end + ( <_9,_8,_7> when 'true' -> + ( primop 'match_fail' + ({'function_clause',_9,_8,_7}) + -| [{'function_name',{'return',3}}] ) + -| ['compiler_generated'] ) + end +'make_hybrid_boot'/4 = + %% Line 195 + fun (_0,_1,_2,_3) -> + catch + %% Line 196 + apply 'do_make_hybrid_boot'/4 + (_0, _1, _2, _3) +'do_make_hybrid_boot'/4 = + %% Line 197 + fun (_0,_1,_2,_3) -> + %% Line 198 + case call 'erlang':'binary_to_term' + (_1) of + <{'script',{_X_RelName1,_X_RelVsn1},OldScript}> when 'true' -> + %% Line 199 + case call 'erlang':'binary_to_term' + (_2) of + <{'script',{NewRelName,_X_RelVsn2},NewScript}> when 'true' -> + let = + fun (_6) -> + %% Line 202 + case _6 of + <{'progress','kernel_load_completed'}> when 'true' -> + 'false' + %% Line 203 + <_41> when 'true' -> + 'true' + end + in %% Line 205 + case call 'lists':'splitwith' + (Fun1, OldScript) of + <{_X_OldKernelLoad,OldRest1}> when 'true' -> + %% Line 206 + case call 'lists':'splitwith' + (Fun1, NewScript) of + <{NewKernelLoad,NewRest1}> when 'true' -> + let = + fun (_11) -> + %% Line 208 + case _11 of + <{'progress','modules_loaded'}> when 'true' -> + 'false' + %% Line 209 + <_42> when 'true' -> + 'true' + end + in %% Line 211 + case call 'lists':'splitwith' + (Fun2, OldRest1) of + <{OldModLoad,OldRest2}> when 'true' -> + %% Line 212 + case call 'lists':'splitwith' + (Fun2, NewRest1) of + <{NewModLoad,NewRest2}> when 'true' -> + let = + fun (_16) -> + %% Line 214 + case _16 of + <{'kernelProcess',_43,_44}> when 'true' -> + 'false' + %% Line 215 + <_45> when 'true' -> + 'true' + end + in %% Line 217 + case call 'lists':'splitwith' + (Fun3, OldRest2) of + <{OldPaths,OldRest3}> when 'true' -> + %% Line 218 + case call 'lists':'splitwith' + (Fun3, NewRest2) of + <{NewPaths,NewRest3}> when 'true' -> + let = + fun (_21) -> + %% Line 220 + case _21 of + <{'progress','init_kernel_started'}> when 'true' -> + 'false' + %% Line 221 + <_46> when 'true' -> + 'true' + end + in %% Line 223 + case call 'lists':'splitwith' + (Fun4, OldRest3) of + <{_X_OldKernelProcs,OldApps}> when 'true' -> + %% Line 224 + case call 'lists':'splitwith' + (Fun4, NewRest3) of + <{NewKernelProcs,NewApps}> when 'true' -> + let = + apply %% Line 230 + 'get_regexp_path'/0 + () + in let = + apply %% Line 231 + 'replace_module_load'/3 + (%% Line 231 + OldModLoad, %% Line 231 + NewModLoad, %% Line 231 + MatchPaths) + in let = + apply %% Line 232 + 'replace_paths'/3 + (%% Line 232 + OldPaths, %% Line 232 + NewPaths, %% Line 232 + MatchPaths) + in %% Line 234 + case apply 'get_apps'/3 + (NewApps, 'undefined', 'undefined') of + <{Stdlib,Sasl}> when 'true' -> + let = + apply %% Line 235 + 'replace_apps'/3 + (%% Line 235 + OldApps, %% Line 235 + Stdlib, %% Line 235 + Sasl) + in let = + apply %% Line 236 + 'add_apply_upgrade'/2 + (%% Line 236 + Apps0, _3) + in let <_32> = + call %% Line 238 + 'erlang':%% Line 238 + '++' + (%% Line 238 + NewKernelProcs, %% Line 238 + Apps) + in let <_33> = + call %% Line 238 + 'erlang':%% Line 238 + '++' + (%% Line 238 + Paths, _32) + in let <_34> = + call %% Line 238 + 'erlang':%% Line 238 + '++' + (%% Line 238 + ModLoad, _33) + in let