Skip to content

Commit

Permalink
Merge branch 'main' into bellmar/swaps
Browse files Browse the repository at this point in the history
  • Loading branch information
mbellotti committed Apr 14, 2023
2 parents 1281fdc + 8d19f1e commit 9e9ecd6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func Execute(spec string, path string, flags map[string]bool /*specType bool, te
stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)

p := parser.NewFaultParser(stream)

l := NewListener(path, flags["testing"], flags["skipRun"])

if flags["specType"] {
Expand Down
3 changes: 3 additions & 0 deletions llvm/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ func NewCompiler() *Compiler {
return c
}


func Execute(tree *ast.Spec, specRec map[string]*preprocess.SpecRecord, uncertains map[string][]float64, unknowns []string, aliases map[string]string, testing bool) *Compiler {
compiler := NewCompiler()
compiler.LoadMeta(specRec, uncertains, unknowns, aliases, testing)

err := compiler.Compile(tree)
if err != nil {
panic(err)
Expand All @@ -116,6 +118,7 @@ func Execute(tree *ast.Spec, specRec map[string]*preprocess.SpecRecord, uncertai
}

func (c *Compiler) LoadMeta(structs map[string]*preprocess.SpecRecord, uncertains map[string][]float64, unknowns []string, aliases map[string]string, test bool) {

c.specStructs = structs
c.Unknowns = unknowns
c.Uncertains = uncertains
Expand Down
2 changes: 2 additions & 0 deletions llvm/llvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,12 +729,14 @@ func prepTest(test string, specType bool) (string, error) {

l := listener.Execute(test, "", flags)
pre := preprocess.Execute(l)

ty := types.Execute(pre.Processed, pre)
sw := swaps.NewPrecompiler(ty)
tree := sw.Swap(ty.Checked)
compiler := NewCompiler()
compiler.LoadMeta(ty.SpecStructs, l.Uncertains, l.Unknowns, sw.Alias, true)
err := compiler.Compile(tree)

if err != nil {
return "", err
}
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (
_ "github.com/olekukonko/tablewriter"
)


func parse(data string, path string, file string, filetype string, reach bool, visu bool) (*ast.Spec, *listener.FaultListener, *types.Checker, string, map[string]string) {

//Confirm that the filetype and file declaration match
if !validate_filetype(data, filetype) {
log.Fatalf("malformatted file: declaration does not match filetype.")
Expand Down Expand Up @@ -119,8 +121,9 @@ func run(filepath string, mode string, input string, reach bool) {
fmt.Println(lstnr.AST)
return
}

compiler := llvm.Execute(tree, ty.SpecStructs, lstnr.Uncertains, lstnr.Unknowns, alias, false)

uncertains = compiler.Uncertains
unknowns = compiler.Unknowns

Expand Down
2 changes: 2 additions & 0 deletions preprocess/preprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ func TestRunInstances(t *testing.T) {
t.Fatalf("flow property value not correctly named in runblock got=%s", buzz.Properties["foo"].Value.(ast.Nameable).IdString())
}


run := process.Processed.Statements[3].(*ast.ForStatement).Inits.Statements[0].(*ast.ExpressionStatement).Expression.(*ast.StructInstance)

for k, v := range run.Properties {
if k == "fizz" {
foo := v.Value.(*ast.FunctionLiteral).Body.Statements[0].(*ast.ExpressionStatement).Expression.(*ast.InfixExpression).Left.(*ast.ParameterCall).IdString()
Expand Down
1 change: 1 addition & 0 deletions types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ func TestSwapError3(t *testing.T) {
}
}


func prepTest(test string, specType bool) (*Checker, error) {
flags := make(map[string]bool)
flags["specType"] = specType
Expand Down

0 comments on commit 9e9ecd6

Please sign in to comment.