-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added -objdump argument to print circuit statistics. Refactored
circuit file name suffix handling.
- Loading branch information
1 parent
94d05e5
commit 37f95a2
Showing
7 changed files
with
93 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// main.go | ||
// | ||
// Copyright (c) 2019-2022 Markku Rossi | ||
// | ||
// All rights reserved. | ||
// | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/markkurossi/mpc/circuit" | ||
"github.com/markkurossi/tabulate" | ||
) | ||
|
||
func dumpObjects(files []string) error { | ||
type oCircuit struct { | ||
name string | ||
circuit *circuit.Circuit | ||
} | ||
var circuits []oCircuit | ||
|
||
for _, file := range files { | ||
if circuit.IsFilename(file) { | ||
c, err := circuit.Parse(file) | ||
if err != nil { | ||
return err | ||
} | ||
circuits = append(circuits, oCircuit{ | ||
name: file, | ||
circuit: c, | ||
}) | ||
} | ||
} | ||
|
||
if len(circuits) > 0 { | ||
tab := tabulate.New(tabulate.Github) | ||
tab.Header("File") | ||
tab.Header("XOR").SetAlign(tabulate.MR) | ||
tab.Header("XNOR").SetAlign(tabulate.MR) | ||
tab.Header("AND").SetAlign(tabulate.MR) | ||
tab.Header("OR").SetAlign(tabulate.MR) | ||
tab.Header("INV").SetAlign(tabulate.MR) | ||
tab.Header("Gates").SetAlign(tabulate.MR) | ||
tab.Header("xor").SetAlign(tabulate.MR) | ||
tab.Header("!xor").SetAlign(tabulate.MR) | ||
tab.Header("Wires").SetAlign(tabulate.MR) | ||
|
||
for _, c := range circuits { | ||
row := tab.Row() | ||
row.Column(c.name) | ||
c.circuit.TabulateRow(row) | ||
} | ||
|
||
tab.Print(os.Stdout) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters