Commit 777b1d10 authored by ='s avatar =

Basic typing from file seems to work

parent 704a55da
......@@ -31,27 +31,33 @@ object ChoosePrecisionPhase extends DaisyPhase {
val fncsToConsider: Seq[String] = functionsToConsider(ctx, prg)
var randomMP = false
var precFile = ""
for (opt <- ctx.options) opt match {
case FlagOption("randomMP") => randomMP = true
// case ParamOption("precFile") =>
case ParamOption("precFile", p) => precFile = p
case _ =>
}
if(randomMP && precFile != "")
reporter.fatalError("You can only use precFile XOR randomMP.")
//val (fncIdMap, varIdMap) = buildIdentifier(prg)
//val identifierMap = parseFile(fileName, fncIdMap, varIdMap, reporter, prg.id)
// need to introduce downcasts qnd check before thqt?
var varPrecisionMap: Map[Identifier, Map[Identifier, Precision]] = Map()
val uniformPrecision = ctx.constantPrecision
prg.defs.filter(fnc =>
!fnc.precondition.isEmpty &&
!fnc.body.isEmpty &&
fncsToConsider.contains(fnc.id.toString)).map(fnc => {
var precisionMap: Map[Identifier, Precision] = Map()
// todo: need to change program to match this precisionMap?
if(precFile != ""){
val (fncIdMap, varIdMap) = buildIdentifierMap(prg)
varPrecisionMap = parseFile(precFile, fncIdMap, varIdMap, reporter, prg.id)
// need to check typing and complete it (with max available precision?) if needed.
} else {
prg.defs.filter(fnc =>
!fnc.precondition.isEmpty &&
!fnc.body.isEmpty &&
fncsToConsider.contains(fnc.id.toString)).map(fnc => {
var precisionMap: Map[Identifier, Precision] = Map()
// todo: need to change program to match this precisionMap?
if(randomMP) {
precisionMap = precisionMap ++ fnc.params.map(e => e match { case ValDef(v) => (v -> getRandomPrecision())}).toMap
fnc.body match {
......@@ -62,10 +68,10 @@ object ChoosePrecisionPhase extends DaisyPhase {
} else {
precisionMap = allVariablesOf(fnc.body.get).map(id => (id -> uniformPrecision)).toMap
}
reporter.info(s"Chosen Precision map is for ${fnc.id} ${precisionMap.toString}")
varPrecisionMap += fnc.id -> precisionMap
})
reporter.info(s"Chosen Precision map is for ${fnc.id} ${precisionMap.toString}")
varPrecisionMap += fnc.id -> precisionMap
})
}
val newprg = Program(prg.id,
prg.defs.map({
case FunDef(id, retT, params, pre, body, post, isField) =>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment