Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 11 additions & 2 deletions src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,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 @@ -501,7 +501,7 @@ function genericPrint(path, options, print) {
} else {
doc = concat(['case ', path.call(print, 'value')]);
}
return join(' ', [doc, '{}']);
return join(' ', [doc, path.call(print, 'block')]);
case 'AssemblyLocalDefinition':
return join(' ', [
'let',
Expand All @@ -522,6 +522,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
18 changes: 18 additions & 0 deletions tests/Assembly/Assembly.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,22 @@ contract Assembly {
}
}
}

function caseAssembly() {
assembly {
switch value
case 0 {
mstore(0, 0x0000000000000000000000000000000000000000000000000000000000000000)
}
case 1 {
mstore(0, 0x1111111111111111111111111111111111111111111111111111111111111111)
}
}
}

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

function caseAssembly() {
assembly {
switch value
case 0 {
mstore(0, 0x0000000000000000000000000000000000000000000000000000000000000000)
}
case 1 {
mstore(0, 0x1111111111111111111111111111111111111111111111111111111111111111)
}
}
}

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

function caseAssembly() {
assembly {
switch value
case 0 {
mstore(0, 0x0000000000000000000000000000000000000000000000000000000000000000)
}
case 1 {
mstore(0, 0x1111111111111111111111111111111111111111111111111111111111111111)
}
}
}

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)
}
}
}
}

`;