diff options
author | Barry Wardell <barry.wardell@gmail.com> | 2012-02-09 09:49:35 +0000 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2012-02-09 10:14:42 +0000 |
commit | 3f0dc8ca3ddee5c78c6922abc9707d464a2d0506 (patch) | |
tree | 008d2b88e137c272ff34c7a1363a8e3c9196dbe8 /Tools/MathematicaMisc | |
parent | 4b9da3393b67b7b8f75396c6d8e7abef86ee7b27 (diff) | |
parent | 90ef11c6391568bf00fc7258f7f7060a81c0dfe8 (diff) |
Merge remote-tracking branch 'origin/piraha'
Conflicts:
Tools/CodeGen/Kranc.m
Diffstat (limited to 'Tools/MathematicaMisc')
-rw-r--r-- | Tools/MathematicaMisc/Errors.m | 18 | ||||
-rw-r--r-- | Tools/MathematicaMisc/RunKranc.m | 16 |
2 files changed, 27 insertions, 7 deletions
diff --git a/Tools/MathematicaMisc/Errors.m b/Tools/MathematicaMisc/Errors.m index df1c1ee..53cfcd7 100644 --- a/Tools/MathematicaMisc/Errors.m +++ b/Tools/MathematicaMisc/Errors.m @@ -10,6 +10,8 @@ VerifyList; InfoMessage; SetDebugLevel; ErrorDefinition::usage = "ErrorDefinition[f] creates a default definition of a function f which throws an exception. This can be used to catch programming errors where f is called with incorrect arguments."; +PrintError; +TraceExecution; DebugQuiet = 0; Warnings = 1 @@ -96,11 +98,23 @@ ErrorDefinition[x_] := SetAttributes[DefFn, HoldAll]; +TraceExecution = False; +TraceExecutionIndent = ""; + DefFn[def:(fn_[args___] := body_)] := Module[ - {}, + {result = Unique["result"]}, ErrorDefinition[fn]; - fn[args] := (*Profile[fn,*)body(*]*)]; + Quiet[ + fn[args] := + Module[ + {result}, + If[TraceExecution, Print[TraceExecutionIndent, fn," ", Map[InputForm[First[#]] &,{args}]]]; + TraceExecutionIndent="| "<>TraceExecutionIndent; + result2 = body; + TraceExecutionIndent=StringDrop[TraceExecutionIndent,2]; + If[TraceExecution, Print[TraceExecutionIndent, "-> ", InputForm@result2]]; + result2], RuleDelayed::rhs]]; End[]; diff --git a/Tools/MathematicaMisc/RunKranc.m b/Tools/MathematicaMisc/RunKranc.m index b554c9c..3272c2e 100644 --- a/Tools/MathematicaMisc/RunKranc.m +++ b/Tools/MathematicaMisc/RunKranc.m @@ -1,14 +1,15 @@ script = $CommandLine[[-1]]; -krancDir = Environment["KRANCDIR"]; +Kranc`KrancDirectory = Environment["KRANCDIR"]; $Path = Join[$Path, - {krancDir <> "/Tools/CodeGen", - krancDir <> "/Tools/MathematicaMisc", - krancDir <> "/Tools/External"}]; + {Kranc`KrancDirectory <> "/Tools/CodeGen", + Kranc`KrancDirectory <> "/Tools/MathematicaMisc", + Kranc`KrancDirectory <> "/Tools/PirahaPeg"}]; Needs["Errors`"]; Needs["KrancThorn`"]; Needs["Profile`"]; +Needs["KrancScript`"]; If[Environment["KRANCVERBOSE"] == "yes", SetDebugLevel[InfoFull]]; @@ -62,7 +63,12 @@ exception = Catch[Catch[ Check[ Block[ {$RecursionLimit = Infinity}, - (*{result,timers} = GetTimers[ *) Get[script](*]*)]; + + Switch[ + FileExtension[script], + "m", (*{result,timers} = GetTimers[ *) Get[script](*]*), + "kranc", CreateThornFromKrancScript[script], + _, ThrowError["Unknown file extension for "<>script<>". Recognised extensions are .m and .kranc."]]]; (* Put[timers, "timer-output-1.m"]; *) |