Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

52
LINES

< > BotCompany Repo | #1034490 // LASCompileResult - this actually invokes the script compiler

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (33154L) is out of date.

1  
sclass LASCompileResult {
2  
  settable S script;
3  
  settable GazelleV_LeftArrowScriptParser parser;
4  
  settable Throwable compileError;
5  
  /*settable broken*/ GazelleV_LeftArrowScript.Script parsedScript;
6  
  RunResultWithTimestamps compileLog;
7  
8  
  toString {
9  
    if (compileError != null) ret errorToString();
10  
    if (parsedScript == null) ret "Not compiled yet";
11  
    ret "Compiled OK" + (compileLog == null ? ""
12  
      : " in " + n2(max(1, compileLog.duration().toMillis())) + " ms";
13  
  }
14  
  
15  
  bool hasError() { ret compileError != null; }
16  
  
17  
  S errorToString() {
18  
    ret exceptionToStringShorter_dontDropOuterExceptions(compileError);
19  
  }
20  
  
21  
  bool runnable() { ret parsedScript != null; }
22  
23  
  void compile() {  
24  
    compileLog = runResultWithTimestamps_dontPrintStackTrace(-> {
25  
      if (parser == null)
26  
        parser = makeParser();
27  
      ret parsedScript = parser.parse(script);
28  
    });
29  
      
30  
    if (compileLog.isError()) {
31  
      var e = compileLog.getError();
32  
      compileError(e);
33  
    }
34  
  }
35  
  
36  
  GazelleV_LeftArrowScript.Script parsedScript aka get() { ret parsedScript; }
37  
  
38  
  GazelleV_LeftArrowScript.Script parsedScriptMandatory() {
39  
    if (compileError != null) fail(compileError);
40  
    ret parsedScript;
41  
  }
42  
  
43  
  swappable GazelleV_LeftArrowScriptParser makeParser() { null; }
44  
  
45  
  LineAndColumn errorLineAndCol() {
46  
    ret parseLineAndColumn(str(compileError));
47  
  }
48  
  
49  
  Timestamp compilationStart() {
50  
    ret compileLog?.started;
51  
  }
52  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034490
Snippet name: LASCompileResult - this actually invokes the script compiler
Eternal ID of this version: #1034490/23
Text MD5: 637dfb1bed58204a07c6b30e5ec0a096
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-09-19 20:03:48
Source code size: 1494 bytes / 52 lines
Pitched / IR pitched: No / No
Views / Downloads: 271 / 530
Version history: 22 change(s)
Referenced in: [show references]