MCPcopy Create free account
hub / github.com/d1ll0n/stack-packer / parseTypeName

Function parseTypeName

src/parser/parser.ts:21–43  ·  view source on GitHub ↗
(scopeName: string, typeName: AntlrTypeName)

Source from the content-addressed store, hash-verified

19import { string } from 'yargs';
20
21export function parseTypeName(scopeName: string, typeName: AntlrTypeName): TypeName {
22 if (typeName.type == 'ElementaryTypeName') return typeName;
23 if (typeName.type == 'UserDefinedTypeName') {
24 let namePath = (typeName.namePath.includes('.'))
25 ? typeName.namePath : `${scopeName}.${typeName.namePath}`
26 return {...typeName, namePath}
27 }
28 if (typeName.type == 'ArrayTypeName') {
29 const { type, baseTypeName, length } = typeName;
30 return {
31 type,
32 baseTypeName: parseTypeName(scopeName, baseTypeName),
33 length: length ? {
34 number: +(length as NumberLiteral).number,
35 type: 'NumberLiteral'
36 } : null
37 }
38 }
39 if (typeName.type == 'Mapping') {
40 throw new Error(`Caught unencodable type Mapping in ${scopeName}`)
41 }
42 throw new Error(`Did not recognize type ${typeName.type} in ${scopeName}`)
43}
44
45/**
46 * @param scopeName Name of the scope which contains the member (contract.struct)

Callers 1

parseMemberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected