const wrapper = require('bindings')('aslsp-native'); export enum MessageType { Error = 0, Warning = 1, Information = 2 } export enum ASEngineProperty { asEP_ALLOW_UNSAFE_REFERENCES = 1, asEP_OPTIMIZE_BYTECODE = 2, asEP_COPY_SCRIPT_SECTIONS = 3, asEP_MAX_STACK_SIZE = 4, asEP_USE_CHARACTER_LITERALS = 5, asEP_ALLOW_MULTILINE_STRINGS = 6, asEP_ALLOW_IMPLICIT_HANDLE_TYPES = 7, asEP_BUILD_WITHOUT_LINE_CUES = 8, asEP_INIT_GLOBAL_VARS_AFTER_BUILD = 9, asEP_REQUIRE_ENUM_SCOPE = 10, asEP_SCRIPT_SCANNER = 11, asEP_INCLUDE_JIT_INSTRUCTIONS = 12, asEP_STRING_ENCODING = 13, asEP_PROPERTY_ACCESSOR_MODE = 14, asEP_EXPAND_DEF_ARRAY_TO_TMPL = 15, asEP_AUTO_GARBAGE_COLLECT = 16, asEP_DISALLOW_GLOBAL_VARS = 17, asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT = 18, asEP_COMPILER_WARNINGS = 19, asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE = 20, asEP_ALTER_SYNTAX_NAMED_ARGS = 21, asEP_DISABLE_INTEGER_DIVISION = 22, asEP_DISALLOW_EMPTY_LIST_ELEMENTS = 23, asEP_PRIVATE_PROP_AS_PROTECTED = 24, asEP_ALLOW_UNICODE_IDENTIFIERS = 25, asEP_HEREDOC_TRIM_MODE = 26, asEP_MAX_NESTED_CALLS = 27, asEP_GENERIC_CALL_MODE = 28, asEP_INIT_STACK_SIZE = 29, asEP_INIT_CALL_STACK_SIZE = 30, asEP_MAX_CALL_STACK_SIZE = 31, } export interface Message { section: string, row: number, col: number, type: MessageType, message: string } export interface ScriptDatabase { setEngineProperty(property: ASEngineProperty, value: number): void; reset(): void; loadScript(name: string, script: string): void; build(): number; messages(): Message[]; } export function BuildDatabase(): ScriptDatabase { return new wrapper.Database(); } export function testRun(): void { const db = module.exports.BuildDatabase(); db.loadScript("m.as", "int foo(){return 10}"); db.build(); let messages = db.messages(); console.log("Build 1"); for (let i = 0; i < messages.length; i++) { console.log(messages[i]); } db.loadScript("m.as", "int foo(){return 10;}"); db.build(); messages = db.messages(); console.log("Build 2"); for (let i = 0; i < messages.length; i++) { console.log(messages[i]); } db.reset(); db.loadScript("m.as", "int foo(){return 10}"); db.build(); messages = db.messages(); console.log("Build 3"); for (let i = 0; i < messages.length; i++) { console.log(messages[i]); } }