Overte C++ Documentation
ScriptProgram.h
1 //
2 // ScriptProgram.h
3 // libraries/script-engine/src
4 //
5 // Created by Heather Anderson on 5/2/21.
6 // Copyright 2021 Vircadia contributors.
7 // Copyright 2023 Overte e.V.
8 //
9 // Distributed under the Apache License, Version 2.0.
10 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
11 // SPDX-License-Identifier: Apache-2.0
12 //
13 
16 
17 #ifndef hifi_ScriptProgram_h
18 #define hifi_ScriptProgram_h
19 
20 #include <memory>
21 
22 class ScriptProgram;
24 using ScriptProgramPointer = std::shared_ptr<ScriptProgram>;
25 using ScriptSyntaxCheckResultPointer = std::shared_ptr<ScriptSyntaxCheckResult>;
26 
36 public:
37  virtual ScriptSyntaxCheckResultPointer checkSyntax() = 0; //It cannot be const anymore because V8 doesn't have separate syntax checking function
38 
44  virtual QString fileName() const = 0;
45 
51  virtual QString sourceCode() const = 0;
52 
53 protected:
54  ~ScriptProgram() {} // prevent explicit deletion of base class
55 };
56 
57 
66 public:
67 
72  enum State
73  {
74  Error = 0,
76  Valid = 2
77  };
78 
79 public:
80 
86  virtual int errorColumnNumber() const = 0;
87 
93  virtual int errorLineNumber() const = 0;
94 
100  virtual QString errorMessage() const = 0;
101 
107  virtual QString errorBacktrace() const = 0;
108 
114  virtual State state() const = 0;
115 
116 protected:
117  ~ScriptSyntaxCheckResult() {} // prevent explicit deletion of base class
118 };
119 
120 #endif // hifi_ScriptProgram_h
121 
Engine-independent representation of a script program.
Definition: ScriptProgram.h:35
virtual QString fileName() const =0
Returns the filename associated with this program.
virtual QString sourceCode() const =0
Returns the source code of this program.
Engine-independent representation of a script syntax check.
Definition: ScriptProgram.h:65
virtual QString errorBacktrace() const =0
virtual QString errorMessage() const =0
Returns the error message of this ScriptSyntaxCheckResult, or an empty string if there is no error.
virtual State state() const =0
Returns the state of this ScriptSyntaxCheckResult.
virtual int errorColumnNumber() const =0
Returns the error column number of this ScriptSyntaxCheckResult, or -1 if there is no error.
virtual int errorLineNumber() const =0
Returns the error line number of this ScriptSyntaxCheckResult, or -1 if there is no error.
State
State of the syntax check.
Definition: ScriptProgram.h:73
@ Intermediate
Definition: ScriptProgram.h:75
@ Valid
Definition: ScriptProgram.h:76