Skip to content

Commit

Permalink
Add ability to generate Rubi binary snapshot.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Nov 10, 2018
1 parent 668a657 commit fe5a81f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
2 changes: 2 additions & 0 deletions expreduce/builtin_rubi.go
@@ -1,3 +1,5 @@
//go:generate go run ../utils/gensnapshots/gensnapshots.go

package expreduce

func getRubiDefinitions() (defs []Definition) {
Expand Down
4 changes: 2 additions & 2 deletions expreduce/resources.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions expreduce/resources/rubi.m
Expand Up @@ -21,9 +21,8 @@
]
};

expreduceRubiSnapshotLoc = "/tmp/rubi.expred";
LoadRubiSnapshot[] := (
Get[expreduceRubiSnapshotLoc];
LoadRubiSnapshot[snapshotLoc_] := (
Get[snapshotLoc_];
$ContextPath = Prepend[$ContextPath, "Rubi`"];
);
SaveRubiSnapshot[] := Save[expreduceRubiSnapshotLoc, "Rubi`*"];
SaveRubiSnapshot[snapshotLoc_] := Save[snapshotLoc, "Rubi`*"];
27 changes: 27 additions & 0 deletions utils/gensnapshots/gensnapshots.go
@@ -0,0 +1,27 @@
package main

import (
"flag"

"github.com/corywalker/expreduce/expreduce"
"github.com/corywalker/expreduce/expreduce/atoms"
)

var rubiSnapshotLocation = flag.String("rubi_snapshot_location", "/tmp/theRubiSnapshot.expred", "the location to write the Rubi snapshot")

func main() {
flag.Parse()

es := expreduce.NewEvalState()

es.Eval(atoms.E(
atoms.S("LoadRubi"),
))
res := es.Eval(atoms.E(
atoms.S("SaveRubiSnapshot"),
atoms.NewString(*rubiSnapshotLocation),
))
if !atoms.IsSameQ(res, atoms.S("Null")) {
panic("Unexpected response from SaveRubiSnapshot[]!")
}
}

0 comments on commit fe5a81f

Please sign in to comment.