Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ function genericPrint(path, options, print) {
return concat([
'{',
indent(hardline),
indent(join(line, path.map(print, 'operations'))),
indent(printPreservingEmptyLines(path, 'operations', options, print)),
hardline,
'}'
]);
Expand Down Expand Up @@ -545,6 +545,15 @@ function genericPrint(path, options, print) {
' ',
path.call(print, 'body')
]);
case 'AssemblyFor': {
return join(' ', [
'for',
path.call(print, 'pre'),
path.call(print, 'condition'),
path.call(print, 'post'),
path.call(print, 'body')
]);
}
case 'FunctionTypeName': {
const returns = returnTypes => {
if (returnTypes.length > 0) {
Expand Down
6 changes: 6 additions & 0 deletions tests/Assembly/Assembly.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ contract Assembly {
}
}
}

function forAssembly() {
assembly {
for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
}
}
}
18 changes: 18 additions & 0 deletions tests/Assembly/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ contract Assembly {
}
}
}

function forAssembly() {
assembly {
for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
contract Assembly {
Expand All @@ -44,6 +50,18 @@ contract Assembly {
}
}
}

function forAssembly() {
assembly {
for {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree with you, this seems a little bit odd but that's a good starting point; I'll wait for you to address #92 and then we can merge both

let i := 0
} lt(i, x) {
i := add(i, 1)
} {
y := mul(2, y)
}
}
}
}

`;