@abaplint/core 2.119.57 → 2.119.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -618,6 +618,9 @@ export declare class BuiltIn {
618
618
  static readonly filename = "_builtin.prog.abap";
619
619
  private static counter;
620
620
  private static readonly getCache;
621
+ private static typesCache;
622
+ private static extrasCacheKey;
623
+ private static extrasCache;
621
624
  static readonly methods: {
622
625
  [name: string]: IBuiltinMethod;
623
626
  };
@@ -129,16 +129,20 @@ class BuiltIn {
129
129
  return def.predicate;
130
130
  }
131
131
  getTypes() {
132
- const ret = this.buildSY();
133
- {
134
- const id = new tokens_1.Identifier(new position_1.Position(1, 1), "abap_bool");
135
- ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, new basic_1.CharacterType(1, { qualifiedName: "ABAP_BOOL", ddicName: "ABAP_BOOL" })));
132
+ // the identifiers are identical for every object, share them to reduce memory usage
133
+ if (BuiltIn.typesCache === undefined) {
134
+ const ret = this.buildSY();
135
+ {
136
+ const id = new tokens_1.Identifier(new position_1.Position(1, 1), "abap_bool");
137
+ ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, new basic_1.CharacterType(1, { qualifiedName: "ABAP_BOOL", ddicName: "ABAP_BOOL" })));
138
+ }
139
+ {
140
+ const id = new tokens_1.Identifier(new position_1.Position(1, 1), "cursor");
141
+ ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, basic_1.IntegerType.get({ qualifiedName: "CURSOR", ddicName: "CURSOR" })));
142
+ }
143
+ BuiltIn.typesCache = ret;
136
144
  }
137
- {
138
- const id = new tokens_1.Identifier(new position_1.Position(1, 1), "cursor");
139
- ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, basic_1.IntegerType.get({ qualifiedName: "CURSOR", ddicName: "CURSOR" })));
140
- }
141
- return ret;
145
+ return BuiltIn.typesCache;
142
146
  }
143
147
  get(extras) {
144
148
  const ret = [];
@@ -171,10 +175,17 @@ class BuiltIn {
171
175
  BuiltIn.getCache.push(this.buildConstant("space", new basic_1.CharacterType(1, { derivedFromConstant: true }), "' '"));
172
176
  }
173
177
  ret.push(...BuiltIn.getCache);
174
- for (const e of extras) {
175
- const id = new tokens_1.Identifier(new position_1.Position(this.row++, 1), e);
176
- ret.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, basic_1.VoidType.get(e), ["read_only" /* IdentifierMeta.ReadOnly */, "built-in" /* IdentifierMeta.BuiltIn */], "'?'"));
178
+ // the extras are identical for every object, share them to reduce memory usage
179
+ const key = extras.join("|");
180
+ if (key !== BuiltIn.extrasCacheKey) {
181
+ BuiltIn.extrasCacheKey = key;
182
+ BuiltIn.extrasCache = [];
183
+ for (const e of extras) {
184
+ const id = new tokens_1.Identifier(new position_1.Position(this.row++, 1), e);
185
+ BuiltIn.extrasCache.push(new _typed_identifier_1.TypedIdentifier(id, BuiltIn.filename, basic_1.VoidType.get(e), ["read_only" /* IdentifierMeta.ReadOnly */, "built-in" /* IdentifierMeta.BuiltIn */], "'?'"));
186
+ }
177
187
  }
188
+ ret.push(...BuiltIn.extrasCache);
178
189
  return ret;
179
190
  }
180
191
  /////////////////////////////
@@ -383,6 +394,9 @@ exports.BuiltIn = BuiltIn;
383
394
  BuiltIn.filename = "_builtin.prog.abap";
384
395
  BuiltIn.counter = 1;
385
396
  BuiltIn.getCache = [];
397
+ BuiltIn.typesCache = undefined;
398
+ BuiltIn.extrasCacheKey = undefined;
399
+ BuiltIn.extrasCache = [];
386
400
  // todo: "pcre" vs "regex", only one of these parameters are allowed
387
401
  // todo: "pcre", only possible from 755
388
402
  BuiltIn.methods = {
@@ -1,15 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractNode = void 0;
4
+ // shared constant, so nodes without children don't waste memory on empty arrays
5
+ const EMPTY = Object.freeze([]);
4
6
  class AbstractNode {
5
7
  constructor() {
6
- this.children = [];
8
+ this.children = EMPTY;
7
9
  }
8
10
  addChild(n) {
11
+ if (this.children === EMPTY) {
12
+ this.children = [];
13
+ }
9
14
  this.children.push(n);
10
15
  }
11
16
  setChildren(children) {
12
- this.children = children;
17
+ // copy, input arrays are built via push() and carry over-allocated backing stores
18
+ this.children = children.slice();
13
19
  }
14
20
  getChildren() {
15
21
  return this.children;
@@ -11,17 +11,13 @@ const string_template_middle_1 = require("../1_lexer/tokens/string_template_midd
11
11
  const string_template_end_1 = require("../1_lexer/tokens/string_template_end");
12
12
  const string_template_begin_1 = require("../1_lexer/tokens/string_template_begin");
13
13
  const string_template_1 = require("../1_lexer/tokens/string_template");
14
+ const EMPTY_PRAGMAS = Object.freeze([]);
14
15
  class StatementNode extends _abstract_node_1.AbstractNode {
15
16
  constructor(statement, colon, pragmas) {
16
17
  super();
17
18
  this.statement = statement;
18
19
  this.colon = colon;
19
- if (pragmas) {
20
- this.pragmas = pragmas;
21
- }
22
- else {
23
- this.pragmas = [];
24
- }
20
+ this.pragmas = pragmas !== null && pragmas !== void 0 ? pragmas : EMPTY_PRAGMAS;
25
21
  }
26
22
  get() {
27
23
  return this.statement;
@@ -36,7 +32,7 @@ class StatementNode extends _abstract_node_1.AbstractNode {
36
32
  if (children.length === 0) {
37
33
  throw new Error("statement: zero children");
38
34
  }
39
- this.children = children;
35
+ super.setChildren(children);
40
36
  return this;
41
37
  }
42
38
  getStart() {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TokenNode = void 0;
4
+ const EMPTY_CHILDREN = Object.freeze([]);
4
5
  class TokenNode {
5
6
  constructor(token) {
6
7
  this.token = token;
@@ -12,7 +13,7 @@ class TokenNode {
12
13
  throw new Error("TokenNode, Method not implemented.");
13
14
  }
14
15
  getChildren() {
15
- return [];
16
+ return EMPTY_CHILDREN;
16
17
  }
17
18
  concatTokens() {
18
19
  return this.token.getStr();
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.119.57";
78
+ return "2.119.58";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.119.57",
3
+ "version": "2.119.58",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",