Skip to content

Commit

Permalink
Format sources, add headers, udpate docs expload#231
Browse files Browse the repository at this point in the history
  • Loading branch information
vovapolu committed Sep 27, 2018
1 parent b8fe586 commit 52e45a0
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 19 deletions.
8 changes: 4 additions & 4 deletions cli/src/main/scala/pravda/cli/PravdaConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ object PravdaConfig {
sealed trait CompileMode

object CompileMode {
case object Nope extends CompileMode
case object Asm extends CompileMode
case object Disasm extends CompileMode
case object DotNet extends CompileMode
case object Nope extends CompileMode
case object Asm extends CompileMode
case object Disasm extends CompileMode
case object DotNet extends CompileMode
}

case object Nope extends PravdaConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ final class CompilersLanguageImpl(implicit executionContext: ExecutionContext) e
def dotnet(sources: Seq[(ByteString, Option[ByteString])],
mainClass: Option[String]): Future[Either[String, ByteString]] = Future {
for {
files <- sources.map {
case (pe, pdb) => FileParser.parseDotnetFile(pe.toByteArray, pdb.map(_.toByteArray))
}.toList.sequence
files <- sources
.map {
case (pe, pdb) => FileParser.parseDotnetFile(pe.toByteArray, pdb.map(_.toByteArray))
}
.toList
.sequence
ops <- DotnetTranslator.translateAsm(files, mainClass).left.map(_.mkString)
} yield PravdaAssembler.assemble(ops, saveLabels = true)
}
Expand Down
6 changes: 3 additions & 3 deletions cli/src/test/scala/pravda/cli/programs/CompileSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ object CompileSuite extends TestSuite {
UnexpectedStringOutput
def dotnet(sources: Seq[(ByteString, Option[ByteString])],
mainClass: Option[String]): Id[Either[String, ByteString]] = {
if (sources.headOption.map(_._1).contains(BinarySource)) Right(ExpectedBinaryOutput)
else Right(UnexpectedBinaryOutput)
}
if (sources.headOption.map(_._1).contains(BinarySource)) Right(ExpectedBinaryOutput)
else Right(UnexpectedBinaryOutput)
}
}
val compile = new Compile[Id](io, compilers)
compile(PravdaConfig.Compile(DotNet))
Expand Down
2 changes: 1 addition & 1 deletion doc/ref/cli/pravda-compile-asm.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
THIS FILE IS GENERATED. DO NOT EDIT MANUALLY!
-->

```pravda compile asm --input <file> --output <file>```
```pravda compile asm --input <sequence> --output <file>```

## Description
Assemble Pravda VM bytecode from text representation. Input file is a Pravda assembly language text file. Output is binary Pravda program. By default read from stdin and print to stdout.
Expand Down
2 changes: 1 addition & 1 deletion doc/ref/cli/pravda-compile-disasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
THIS FILE IS GENERATED. DO NOT EDIT MANUALLY!
-->

```pravda compile disasm --input <file> --output <file>```
```pravda compile disasm --input <sequence> --output <file>```

## Description
Disassemble Pravda VM bytecode to text presentation. Input file is a Pravda executable binary. Output is a text file with Pravda assembly code. By default read from stdin and print to stdout.
Expand Down
5 changes: 2 additions & 3 deletions doc/ref/cli/pravda-compile-dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
THIS FILE IS GENERATED. DO NOT EDIT MANUALLY!
-->

```pravda compile dotnet --input <file> --output <file> --visualize --pdb <file>```
```pravda compile dotnet --input <sequence> --output <file> --main-class <string>```

## Description
Compile .exe produced by .NET compiler to Pravda VM bytecode. Input file is a .NET PE (portable executable). Output is binary Pravdaprogram. By default read from stdin and print to stdout
Expand All @@ -12,5 +12,4 @@ Compile .exe produced by .NET compiler to Pravda VM bytecode. Input file is a .N
|----|----|
|`-i`, `--input`|Input file
|`-o`, `--output`|Output file
|`--visualize`|Visualize translation. Prints asm commands along with source CIL opcodes.
|`--pdb`|Pdb file with debug information obtained from .NET compilation.
|`--main-class`|Full name of class that should be compile to Pravda program
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* Copyright (C) 2018 Expload.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package pravda.dotnet.translation.opcode
import com.google.protobuf.ByteString
import pravda.dotnet.translation.data.{MethodTranslation, OpCodeTranslation}
Expand Down
3 changes: 2 additions & 1 deletion dotnet/src/test/scala/pravda/dotnet/TranslationSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ object TranslationSuite extends Proverka {
parseDotnetFile(dll, pdbO)
}
}
.toList.sequence
.toList
.sequence

for {
files <- filesE
Expand Down
6 changes: 3 additions & 3 deletions yopt/src/test/scala/pravda/yopt/CommandLineTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ object CommandLineTest extends TestSuite {

def otherTypesParser[T](expectedValue: T, args: String*)(slice: Config => T): Unit = {
otherTypesParser.parse(args.toList, Config()) match {
case Ok(r) => slice(r) ==> expectedValue
case ParseError(msg) => Predef.assert(false, msg)
case _ => assert(false)
case Ok(r) => slice(r) ==> expectedValue
case ParseError(msg) => Predef.assert(false, msg)
case _ => assert(false)
}
}

Expand Down

0 comments on commit 52e45a0

Please sign in to comment.