Warning: session_start(): open(/var/lib/php/sessions/sess_93g7k3ssgcsj4bm6fau7ahb0ni, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
concept EvaluationResult {
S code;
S safety;
S comments;
S date;
}
concept CAction {
S action, date;
}
cmodule CodeSafetyAnalysis > DynCRUD {
transient ReliableSingleThread rstCalc = dm_rst(me(), r calc);
transient SingleComponentPanel scpSuggestions;
transient CRUD crudActions;
S code;
PairS safety; // tested code + safety result
Set unknownIdentifiers;
start {
addCountToName = false;
crudActions = new CRUD(CAction);
dm_useLocalMechListCopies();
dm_watchFieldAndNow code(rstCalc);
}
visual withComputing(rstCalc, jvsplit(
centerAndSouthWithMargins(
jhsplit(
dm_textAreaAsSection code(),
jCenteredSection("Suggestions", scpSuggestions = singleComponentPanel())),
centerAndEast(jCenteredSection("Safety", dm_calculatedLabel(() -> pairB(safety))), jbutton("Save result", rThreadEnter saveResult))
),
jhsplit(
jCenteredSection("Past Results", super),
jCenteredSection("Last Actions", crudActions.visualize())));
void calc {
S code = this.code;
setField(safety := pair(code, codeSafetyCheckResult(code)));
setField(unknownIdentifiers := codeAnalysis_getUnknownIdentifiers(code));
setComponent(scpSuggestions, () -> scrollableStackWithSpacing(
map(unknownIdentifiers, id ->
jLabelWithButtonsAndSideMargin(id,
"Mark safe", rThreadEnter { recordAction(quote(id) + " marked safe"); markSafe(id); rstCalc.trigger(); },
"Mark UNsafe", rThreadEnter { recordAction(quote(id) + " marked unsafe"); markUnsafe(id); rstCalc.trigger(); },
"Mark...", rThreadEnter { inputText("Mark identifier " + quote(id), "unsafe", safety -> { assertIdentifier(safety = trim(safety)); recordAction(quote(id) + " marked " + safety); markIdentifier(id, safety); }) },
))));
}
void saveResult {
rstCalc.waitUntilDone();
PairS p = safety;
if (p != null)
cnew EvaluationResult(code := p.a, safety := p.b, date := formatLocalDateWithSeconds());
}
void recordAction(S action) {
cnew(CAction, date := formatLocalDateWithSeconds(), +action);
}
}