Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Add returns to function declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
recmo committed Oct 11, 2018
1 parent 62c0699 commit fd9d44b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/sol-meta/src/unparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ const visitor = {
`modifier ${name}${Array.isArray(parameters) ? '' : unparse(parameters)} ${unparse(body)}`,
// Note: when there is no parameter block, instead of an ASTNode there is a []

FunctionDefinition: ({visibility, name, parameters, body, modifiers, isConstructor, stateMutability}) =>
FunctionDefinition: ({visibility, name, parameters, body, modifiers, isConstructor, stateMutability, returnParameters}) => // TODO Return type
(isConstructor ? 'constructor' : `function ${name}`) +
unparse(parameters) + ' ' +
(visibility && visibility != 'default' ? visibility + ' ' : '') + (stateMutability || '') + '\n' +
indent(modifiers.map(unparse).join('\n')) + '\n' +
unparse(parameters) + '\n' +
indent(
(visibility && visibility != 'default' ? visibility + ' ' : '') + (stateMutability || '') +
modifiers.map(unparse).join('\n') +
(returnParameters ? `\nreturns ${unparse(returnParameters)}` : '')
) + '\n' +
(body ? unparse(body) : ';'),

ParameterList: ({parameters}) =>
Expand All @@ -79,7 +82,7 @@ const visitor = {
(initialValue ? ` = ${unparse(initialValue)};` : ';'),

ExpressionStatement: ({expression}) =>
`${unparse(expression)};`,
`${unparen(unparse(expression))};`,

EmitStatement: ({eventCall}) =>
`emit ${unparen(unparse(eventCall))};`,
Expand Down Expand Up @@ -195,7 +198,7 @@ const visitor = {
`switch ${unparse(expression)}\n${cases.map(unparse).join('\n')}`,

AssemblyCase: ({value, block}) =>
`case ${unparse(value)} ${unparse(block)}`
`case ${unparse(value)} ${unparse(block)}`,

DecimalNumber: ({ value }) =>
value,
Expand Down

0 comments on commit fd9d44b

Please sign in to comment.