factorize typeuse rule
This commit is contained in:
@@ -272,7 +272,7 @@ resulttypes :: { [ValueType] }
|
|||||||
: list(resulttype) { concat $1 }
|
: list(resulttype) { concat $1 }
|
||||||
|
|
||||||
resulttype :: { [ValueType] }
|
resulttype :: { [ValueType] }
|
||||||
: '(' 'result' list1(valtype) ')' { $3 }
|
: '(' 'result' list(valtype) ')' { $3 }
|
||||||
|
|
||||||
limits :: { Limit }
|
limits :: { Limit }
|
||||||
: u32 u32 { Limit (fromIntegral $1) (Just $ fromIntegral $2) }
|
: u32 u32 { Limit (fromIntegral $1) (Just $ fromIntegral $2) }
|
||||||
@@ -494,9 +494,25 @@ typedef :: { TypeDef }
|
|||||||
: '(' 'type' opt(ident) functype ')' { TypeDef $3 $4 }
|
: '(' 'type' opt(ident) functype ')' { TypeDef $3 $4 }
|
||||||
|
|
||||||
typeuse :: { TypeUse }
|
typeuse :: { TypeUse }
|
||||||
: '(' 'type' typeidx ')' { IndexedTypeUse $3 Nothing }
|
: '(' typeuse1 { $2 }
|
||||||
| '(' 'type' typeidx paramtypes resulttypes ')' { IndexedTypeUse $3 (Just $ FuncType $4 $5) }
|
| {- empty -} { AnonimousTypeUse $ FuncType [] [] }
|
||||||
| paramtypes resulttypes { AnonimousTypeUse $ FuncType $1 $2 }
|
|
||||||
|
typeuse1 :: { TypeUse }
|
||||||
|
: 'type' typeidx typedtypeuse { IndexedTypeUse $2 $3 }
|
||||||
|
| paramsresultstypeuse { AnonimousTypeUse $1 }
|
||||||
|
|
||||||
|
typedtypeuse :: { Maybe FuncType }
|
||||||
|
: ')' { Nothing }
|
||||||
|
| '(' paramsresultstypeuse { Just $2 }
|
||||||
|
|
||||||
|
paramsresultstypeuse :: { FuncType }
|
||||||
|
: paramsresultstypeuse '(' paramsresulttypeuse { mergeFuncType $1 $3 }
|
||||||
|
| paramsresulttypeuse { $1 }
|
||||||
|
|
||||||
|
paramsresulttypeuse :: { FuncType }
|
||||||
|
: 'param' list(valtype) ')' { FuncType (map (ParamType Nothing) $2) [] }
|
||||||
|
| 'param' ident valtype ')' { FuncType [ParamType (Just $2) $3] [] }
|
||||||
|
| 'result' list(valtype) ')' { FuncType [] $2 }
|
||||||
|
|
||||||
memarg1 :: { MemArg }
|
memarg1 :: { MemArg }
|
||||||
: opt(offset) opt(align) { MemArg (fromMaybe 0 $1) (fromMaybe 1 $2) }
|
: opt(offset) opt(align) { MemArg (fromMaybe 0 $1) (fromMaybe 1 $2) }
|
||||||
@@ -627,6 +643,9 @@ opt(p)
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
mergeFuncType :: FuncType -> FuncType -> FuncType
|
||||||
|
mergeFuncType (FuncType lps lrs) (FuncType rps rrs) = FuncType (lps ++ rps) (lrs ++ rrs)
|
||||||
|
|
||||||
asUInt32 :: Integer -> Maybe Natural
|
asUInt32 :: Integer -> Maybe Natural
|
||||||
asUInt32 val
|
asUInt32 val
|
||||||
| val >= 0, val < 2 ^ 32 = Just $ fromIntegral val
|
| val >= 0, val < 2 ^ 32 = Just $ fromIntegral val
|
||||||
|
|||||||
Reference in New Issue
Block a user