loreline 0.9.0 → 0.10.0

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.
package/js/loreline.js CHANGED
@@ -1,4 +1,4 @@
1
- let runtime = {}; let globals = {}; // Generated by Haxe 4.3.6
1
+ let runtime = {}; let globals = {}; // Generated by Haxe 4.3.7
2
2
  (function ($hx_exports, $global) { "use strict";
3
3
  $hx_exports["loreline"] = $hx_exports["loreline"] || {};
4
4
  var $hxClasses = {},$estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_;
@@ -4211,11 +4211,13 @@ class loreline_CodeToLorscript {
4211
4211
  this.length = 0;
4212
4212
  this.lineOutput = null;
4213
4213
  this.output = null;
4214
+ this.inputText = null;
4214
4215
  this.input = null;
4215
4216
  this.index = 0;
4216
4217
  }
4217
4218
  process(input) {
4218
4219
  input = StringTools.rtrim(input) + "\n//<END>";
4220
+ this.inputText = input;
4219
4221
  this.input = input;
4220
4222
  this.index = 0;
4221
4223
  this.output = new StringBuf();
@@ -4238,7 +4240,7 @@ class loreline_CodeToLorscript {
4238
4240
  let min = this.inputPosFromProcessedPos(pmin);
4239
4241
  let max = this.inputPosFromProcessedPos(pmax);
4240
4242
  let len = max + 1 - min;
4241
- return funcPos.withOffset(this.input,min,len,funcPos.offset);
4243
+ return funcPos.withOffset(this.inputText,min,len,funcPos.offset);
4242
4244
  }
4243
4245
  inputPosFromProcessedPos(pos) {
4244
4246
  if(pos < 0) {
@@ -5058,7 +5060,7 @@ class loreline_CodeToLorscript {
5058
5060
  if(this.inStatementsBlock() || this.inObjectBlock() || this.inArrayBlock()) {
5059
5061
  let indent = this.nextLineIndentOffset(line,this.index);
5060
5062
  if(StringTools.trim(line).length != 0) {
5061
- if(indent > 0 && !this.endsOrFollowsWithChar(line,123,this.index,{ fileName : "src/loreline/CodeToLorscript.hx", lineNumber : 1061, className : "loreline.CodeToLorscript", methodName : "_add"}) && !this.endsOrFollowsWithChar(line,91,this.index,{ fileName : "src/loreline/CodeToLorscript.hx", lineNumber : 1061, className : "loreline.CodeToLorscript", methodName : "_add"})) {
5063
+ if(indent > 0 && !this.endsOrFollowsWithChar(line,123,this.index,{ fileName : "src/loreline/CodeToLorscript.hx", lineNumber : 1070, className : "loreline.CodeToLorscript", methodName : "_add"}) && !this.endsOrFollowsWithChar(line,91,this.index,{ fileName : "src/loreline/CodeToLorscript.hx", lineNumber : 1070, className : "loreline.CodeToLorscript", methodName : "_add"})) {
5062
5064
  let trimmedLine = StringTools.ltrim(line);
5063
5065
  let isCaseLabel = trimmedLine.startsWith("case ") || trimmedLine.startsWith("case\t") || (trimmedLine == "default" || trimmedLine.startsWith("default ") || trimmedLine.startsWith("default\t"));
5064
5066
  if(isCaseLabel) {
@@ -5080,7 +5082,7 @@ class loreline_CodeToLorscript {
5080
5082
  this.posOffsets.push(this.currentPosOffset);
5081
5083
  }
5082
5084
  } else if(indent < 0 && this.stack.length > 0 && (this.stack[this.stack.length - 1] == 3 || this.stack[this.stack.length - 1] == 4)) {
5083
- if(!this.inObjectBlock() && !this.endsOrFollowsWithChar(line,59,this.index,{ fileName : "src/loreline/CodeToLorscript.hx", lineNumber : 1090, className : "loreline.CodeToLorscript", methodName : "_add"})) {
5085
+ if(!this.inObjectBlock() && !this.endsOrFollowsWithChar(line,59,this.index,{ fileName : "src/loreline/CodeToLorscript.hx", lineNumber : 1099, className : "loreline.CodeToLorscript", methodName : "_add"})) {
5084
5086
  this.currentPosOffset++;
5085
5087
  this.output.b += String.fromCodePoint(59);
5086
5088
  this.posOffsets.push(this.currentPosOffset);
@@ -5102,7 +5104,7 @@ class loreline_CodeToLorscript {
5102
5104
  this.posOffsets.push(this.currentPosOffset);
5103
5105
  }
5104
5106
  }
5105
- } else if(indent == 0 && !this.endsOrFollowsWithChar(line,59,this.index,{ fileName : "src/loreline/CodeToLorscript.hx", lineNumber : 1115, className : "loreline.CodeToLorscript", methodName : "_add"}) && !this.endsOrFollowsWithChar(line,44,this.index,{ fileName : "src/loreline/CodeToLorscript.hx", lineNumber : 1115, className : "loreline.CodeToLorscript", methodName : "_add"})) {
5107
+ } else if(indent == 0 && !this.endsOrFollowsWithChar(line,59,this.index,{ fileName : "src/loreline/CodeToLorscript.hx", lineNumber : 1124, className : "loreline.CodeToLorscript", methodName : "_add"}) && !this.endsOrFollowsWithChar(line,44,this.index,{ fileName : "src/loreline/CodeToLorscript.hx", lineNumber : 1124, className : "loreline.CodeToLorscript", methodName : "_add"})) {
5106
5108
  if(this.inObjectBlock()) {
5107
5109
  this.currentPosOffset++;
5108
5110
  this.output.b += String.fromCodePoint(44);
@@ -5172,7 +5174,7 @@ class loreline_CodeToLorscript {
5172
5174
  }
5173
5175
  }
5174
5176
  error(message) {
5175
- throw haxe_Exception.thrown(new loreline_Error(message,loreline_Position.fromContentAndIndex(this.input,this.index)));
5177
+ throw haxe_Exception.thrown(new loreline_Error(message,loreline_Position.fromContentAndIndex(this.inputText,this.index)));
5176
5178
  }
5177
5179
  }
5178
5180
  $hxClasses["loreline.CodeToLorscript"] = loreline_CodeToLorscript;
@@ -5185,6 +5187,9 @@ class loreline_Equal {
5185
5187
  if(a == b) {
5186
5188
  return true;
5187
5189
  }
5190
+ if(a == null || b == null) {
5191
+ return false;
5192
+ }
5188
5193
  if(loreline_Arrays.isArray(a)) {
5189
5194
  if(loreline_Arrays.isArray(b)) {
5190
5195
  return loreline_Equal.arrayEqual(interpreter,a,b);
@@ -5484,8 +5489,8 @@ class loreline_Functions {
5484
5489
  if(typeof(value) == "string") {
5485
5490
  return value.length > 0;
5486
5491
  }
5487
- if(((value) instanceof Array)) {
5488
- return value.length > 0;
5492
+ if(loreline_Arrays.isArray(value)) {
5493
+ return loreline_Arrays.arrayLength(value) > 0;
5489
5494
  }
5490
5495
  if(typeof(value) == "number" && ((value | 0) === value)) {
5491
5496
  return value != 0;
@@ -5750,7 +5755,7 @@ class loreline_Functions {
5750
5755
  return null;
5751
5756
  }
5752
5757
  has_beat(name) {
5753
- if(((name) instanceof loreline_NBeatDecl)) {
5758
+ if(loreline_RuntimeBeatRef.beatOf(name) != null) {
5754
5759
  return true;
5755
5760
  }
5756
5761
  let nameStr = name;
@@ -5786,8 +5791,8 @@ class loreline_Functions {
5786
5791
  --i;
5787
5792
  }
5788
5793
  return 0;
5789
- } else if(((name) instanceof loreline_NBeatDecl)) {
5790
- return this.interpreter.getBeatVisitCount(name);
5794
+ } else if(loreline_RuntimeBeatRef.beatOf(name) != null) {
5795
+ return this.interpreter.getBeatVisitCount(loreline_RuntimeBeatRef.beatOf(name));
5791
5796
  } else {
5792
5797
  let beat = this.interpreter.resolveBeatByName(name);
5793
5798
  if(beat == null) {
@@ -6871,11 +6876,12 @@ var loreline_RuntimeAccess = $hxEnums["loreline.RuntimeAccess"] = { __ename__:"l
6871
6876
  ,ArrayAccess: ($_=function(pos,array,index) { return {_hx_index:1,pos:pos,array:array,index:index,__enum__:"loreline.RuntimeAccess",toString:$estr}; },$_._hx_name="ArrayAccess",$_.__params__ = ["pos","array","index"],$_)
6872
6877
  ,CharacterAccess: ($_=function(pos,name) { return {_hx_index:2,pos:pos,name:name,__enum__:"loreline.RuntimeAccess",toString:$estr}; },$_._hx_name="CharacterAccess",$_.__params__ = ["pos","name"],$_)
6873
6878
  ,FunctionAccess: ($_=function(pos,name) { return {_hx_index:3,pos:pos,name:name,__enum__:"loreline.RuntimeAccess",toString:$estr}; },$_._hx_name="FunctionAccess",$_.__params__ = ["pos","name"],$_)
6874
- ,BeatAccess: ($_=function(pos,beat) { return {_hx_index:4,pos:pos,beat:beat,__enum__:"loreline.RuntimeAccess",toString:$estr}; },$_._hx_name="BeatAccess",$_.__params__ = ["pos","beat"],$_)
6879
+ ,BeatAccess: ($_=function(pos,ref) { return {_hx_index:4,pos:pos,ref:ref,__enum__:"loreline.RuntimeAccess",toString:$estr}; },$_._hx_name="BeatAccess",$_.__params__ = ["pos","ref"],$_)
6875
6880
  };
6876
6881
  loreline_RuntimeAccess.__constructs__ = [loreline_RuntimeAccess.FieldAccess,loreline_RuntimeAccess.ArrayAccess,loreline_RuntimeAccess.CharacterAccess,loreline_RuntimeAccess.FunctionAccess,loreline_RuntimeAccess.BeatAccess];
6877
6882
  class loreline_RuntimeScope {
6878
- constructor(id,beat,node,beats,state,head,insertion) {
6883
+ constructor(id,beat,node,beats,state,head,insertion,captured) {
6884
+ this.captured = null;
6879
6885
  this.insertion = null;
6880
6886
  this.head = null;
6881
6887
  this.state = null;
@@ -6898,6 +6904,9 @@ class loreline_RuntimeScope {
6898
6904
  if(insertion != null) {
6899
6905
  this.insertion = insertion;
6900
6906
  }
6907
+ if(captured != null) {
6908
+ this.captured = captured;
6909
+ }
6901
6910
  }
6902
6911
  beatByName(name) {
6903
6912
  if(this.beats == null) {
@@ -6920,6 +6929,35 @@ loreline_RuntimeScope.__name__ = "loreline.RuntimeScope";
6920
6929
  Object.assign(loreline_RuntimeScope.prototype, {
6921
6930
  __class__: loreline_RuntimeScope
6922
6931
  });
6932
+ class loreline_RuntimeBeatRef {
6933
+ constructor(beat,stack) {
6934
+ this.beat = beat;
6935
+ this.stack = stack;
6936
+ }
6937
+ static beatOf(value) {
6938
+ if(((value) instanceof loreline_NBeatDecl)) {
6939
+ return value;
6940
+ }
6941
+ if(((value) instanceof loreline_RuntimeBeatRef)) {
6942
+ let ref = value;
6943
+ return ref.beat;
6944
+ }
6945
+ return null;
6946
+ }
6947
+ static beatNameOf(value) {
6948
+ let beat = loreline_RuntimeBeatRef.beatOf(value);
6949
+ if(beat != null) {
6950
+ return beat.name;
6951
+ } else {
6952
+ return null;
6953
+ }
6954
+ }
6955
+ }
6956
+ $hxClasses["loreline.RuntimeBeatRef"] = $hx_exports["loreline"]["RuntimeBeatRef"] = loreline_RuntimeBeatRef;
6957
+ loreline_RuntimeBeatRef.__name__ = "loreline.RuntimeBeatRef";
6958
+ Object.assign(loreline_RuntimeBeatRef.prototype, {
6959
+ __class__: loreline_RuntimeBeatRef
6960
+ });
6923
6961
  class loreline_RuntimeInsertion {
6924
6962
  constructor(id,origin) {
6925
6963
  this.parentNextOptionIndex = 0;
@@ -6985,6 +7023,10 @@ Object.assign(loreline_EvalNext.prototype, {
6985
7023
  });
6986
7024
  class loreline_Interpreter {
6987
7025
  constructor(script,handleDialogue,handleChoice,handleFinish,options) {
7026
+ this._restoreInsertionsCache = null;
7027
+ this._restoreSavedInsertions = null;
7028
+ this._serializingScopes = [];
7029
+ this._saveInsertions = null;
6988
7030
  this._choiceEvalEnabled = [];
6989
7031
  this._choiceEvalTexts = [];
6990
7032
  this.pendingChoiceOptions = null;
@@ -7044,7 +7086,10 @@ class loreline_Interpreter {
7044
7086
  }
7045
7087
  }
7046
7088
  get_currentInsertion() {
7047
- let i = this.stack.length - 1;
7089
+ return this.insertionAtOrBelow(this.stack.length - 1);
7090
+ }
7091
+ insertionAtOrBelow(scopeLevel) {
7092
+ let i = scopeLevel;
7048
7093
  while(i >= 0) {
7049
7094
  let scope = this.stack[i];
7050
7095
  if(scope.insertion != null) {
@@ -7138,6 +7183,7 @@ class loreline_Interpreter {
7138
7183
  }
7139
7184
  save() {
7140
7185
  let insertions = { };
7186
+ this._saveInsertions = insertions;
7141
7187
  let _g = [];
7142
7188
  let _g1 = 0;
7143
7189
  let _g2 = this.stack;
@@ -7175,6 +7221,7 @@ class loreline_Interpreter {
7175
7221
  if(Reflect.fields(insertions).length > 0) {
7176
7222
  result.insertions = insertions;
7177
7223
  }
7224
+ this._saveInsertions = null;
7178
7225
  return result;
7179
7226
  }
7180
7227
  restore(saveData) {
@@ -7188,10 +7235,12 @@ class loreline_Interpreter {
7188
7235
  this.pendingChoiceOptions = null;
7189
7236
  this._choiceEvalTexts.length = 0;
7190
7237
  this._choiceEvalEnabled.length = 0;
7238
+ let restoredInsertions = new haxe_ds_IntMap();
7239
+ this._restoreSavedInsertions = saveData.insertions;
7240
+ this._restoreInsertionsCache = restoredInsertions;
7191
7241
  this.restoreState(this.topLevelState,saveData.state);
7192
7242
  this.restoreCharacters(saveData.characters);
7193
7243
  this.restoreNodeStates(saveData.nodeStates);
7194
- let restoredInsertions = new haxe_ds_IntMap();
7195
7244
  if(!this.restoreStack(saveData.stack,saveData.insertions,restoredInsertions)) {
7196
7245
  this.beatToResume = this.restoreBeatToResume(saveData.stack);
7197
7246
  }
@@ -7220,6 +7269,8 @@ class loreline_Interpreter {
7220
7269
  this._choiceEvalEnabled.push(entry.disabled != true);
7221
7270
  }
7222
7271
  }
7272
+ this._restoreSavedInsertions = null;
7273
+ this._restoreInsertionsCache = null;
7223
7274
  }
7224
7275
  resume() {
7225
7276
  if(this.stack.length == 0) {
@@ -7257,25 +7308,50 @@ class loreline_Interpreter {
7257
7308
  let fields = this.topLevelCharacters.h[character].fields;
7258
7309
  loreline_Objects.setField(this,fields,name,value);
7259
7310
  }
7260
- getStateField(name) {
7261
- let i = this.stack.length - 1;
7311
+ eachResolutionScope(startIndex,visit) {
7312
+ this.walkResolutionScopes(this.stack,startIndex == -1 ? this.stack.length - 1 : startIndex,visit);
7313
+ }
7314
+ walkResolutionScopes(scopes,startIndex,visit) {
7315
+ let i = startIndex;
7262
7316
  while(i >= 0) {
7263
- let scope = this.stack[i];
7317
+ let scope = scopes[i];
7318
+ if(visit(scope)) {
7319
+ return;
7320
+ }
7321
+ if(scope.captured != null) {
7322
+ this.walkResolutionScopes(scope.captured,scope.captured.length - 1,visit);
7323
+ return;
7324
+ }
7325
+ --i;
7326
+ }
7327
+ }
7328
+ getStateField(name) {
7329
+ let found = false;
7330
+ let result = null;
7331
+ let _gthis = this;
7332
+ this.eachResolutionScope(-1,function(scope) {
7264
7333
  if(scope.state != null) {
7265
- if(loreline_Objects.fieldExists(this,scope.state.fields,name)) {
7266
- return loreline_Objects.getField(this,scope.state.fields,name);
7334
+ if(loreline_Objects.fieldExists(_gthis,scope.state.fields,name)) {
7335
+ result = loreline_Objects.getField(_gthis,scope.state.fields,name);
7336
+ found = true;
7337
+ return true;
7267
7338
  }
7268
7339
  }
7269
7340
  if(scope.node != null) {
7270
7341
  let key = scope.node.id.thisVal;
7271
- let stateInNode = this.nodeStates.map._get(key.high,key.low);
7342
+ let stateInNode = _gthis.nodeStates.map._get(key.high,key.low);
7272
7343
  if(stateInNode != null) {
7273
- if(loreline_Objects.fieldExists(this,stateInNode.fields,name)) {
7274
- return loreline_Objects.getField(this,stateInNode.fields,name);
7344
+ if(loreline_Objects.fieldExists(_gthis,stateInNode.fields,name)) {
7345
+ result = loreline_Objects.getField(_gthis,stateInNode.fields,name);
7346
+ found = true;
7347
+ return true;
7275
7348
  }
7276
7349
  }
7277
7350
  }
7278
- --i;
7351
+ return false;
7352
+ });
7353
+ if(found) {
7354
+ return result;
7279
7355
  }
7280
7356
  if(loreline_Objects.fieldExists(this,this.topLevelState.fields,name)) {
7281
7357
  return loreline_Objects.getField(this,this.topLevelState.fields,name);
@@ -7283,26 +7359,31 @@ class loreline_Interpreter {
7283
7359
  return null;
7284
7360
  }
7285
7361
  setStateField(name,value) {
7286
- let i = this.stack.length - 1;
7287
- while(i >= 0) {
7288
- let scope = this.stack[i];
7362
+ let done = false;
7363
+ let _gthis = this;
7364
+ this.eachResolutionScope(-1,function(scope) {
7289
7365
  if(scope.state != null) {
7290
- if(loreline_Objects.fieldExists(this,scope.state.fields,name)) {
7291
- loreline_Objects.setField(this,scope.state.fields,name,value);
7292
- return;
7366
+ if(loreline_Objects.fieldExists(_gthis,scope.state.fields,name)) {
7367
+ loreline_Objects.setField(_gthis,scope.state.fields,name,value);
7368
+ done = true;
7369
+ return true;
7293
7370
  }
7294
7371
  }
7295
7372
  if(scope.node != null) {
7296
7373
  let key = scope.node.id.thisVal;
7297
- let stateInNode = this.nodeStates.map._get(key.high,key.low);
7374
+ let stateInNode = _gthis.nodeStates.map._get(key.high,key.low);
7298
7375
  if(stateInNode != null) {
7299
- if(loreline_Objects.fieldExists(this,stateInNode.fields,name)) {
7300
- loreline_Objects.setField(this,stateInNode.fields,name,value);
7301
- return;
7376
+ if(loreline_Objects.fieldExists(_gthis,stateInNode.fields,name)) {
7377
+ loreline_Objects.setField(_gthis,stateInNode.fields,name,value);
7378
+ done = true;
7379
+ return true;
7302
7380
  }
7303
7381
  }
7304
7382
  }
7305
- --i;
7383
+ return false;
7384
+ });
7385
+ if(done) {
7386
+ return;
7306
7387
  }
7307
7388
  loreline_Objects.setField(this,this.topLevelState.fields,name,value);
7308
7389
  }
@@ -7332,6 +7413,7 @@ class loreline_Interpreter {
7332
7413
  }
7333
7414
  serializeScope(scope,insertions) {
7334
7415
  let result = { id : scope.id};
7416
+ this._serializingScopes.push(scope);
7335
7417
  if(scope.beat != null) {
7336
7418
  result.beat = this.serializeBeatReference(scope.beat);
7337
7419
  }
@@ -7358,6 +7440,18 @@ class loreline_Interpreter {
7358
7440
  if(scope.insertion != null) {
7359
7441
  result.insertion = this.serializeInsertion(scope.insertion,insertions);
7360
7442
  }
7443
+ if(scope.captured != null) {
7444
+ let _g = [];
7445
+ let _g1 = 0;
7446
+ let _g2 = scope.captured;
7447
+ while(_g1 < _g2.length) {
7448
+ let captured = _g2[_g1];
7449
+ ++_g1;
7450
+ _g.push(this.serializeScope(captured,insertions));
7451
+ }
7452
+ result.captured = _g;
7453
+ }
7454
+ this._serializingScopes.pop();
7361
7455
  return result;
7362
7456
  }
7363
7457
  serializeInsertion(insertion,insertions) {
@@ -7529,6 +7623,17 @@ class loreline_Interpreter {
7529
7623
  result[key] = this.serializeValue(value);
7530
7624
  }
7531
7625
  }
7626
+ } else if(js_Boot.getClass(fields) == null) {
7627
+ let _g = 0;
7628
+ let _g1 = Reflect.fields(fields);
7629
+ while(_g < _g1.length) {
7630
+ let key = _g1[_g];
7631
+ ++_g;
7632
+ let value = Reflect.field(fields,key);
7633
+ if(originalFields == null || !loreline_Objects.fieldExists(this,originalFields,key) || !loreline_Equal.equal(this,loreline_Objects.getField(this,originalFields,key),value)) {
7634
+ result[key] = this.serializeValue(value);
7635
+ }
7636
+ }
7532
7637
  } else {
7533
7638
  let cls = js_Boot.getClass(fields);
7534
7639
  if(cls != null) {
@@ -7569,6 +7674,39 @@ class loreline_Interpreter {
7569
7674
  }
7570
7675
  return arr;
7571
7676
  }
7677
+ let asBeat = loreline_RuntimeBeatRef.beatOf(value);
7678
+ if(asBeat != null) {
7679
+ let serializedRef = { type : "$beatRef", beat : this.serializeBeatReference(asBeat)};
7680
+ if(((value) instanceof loreline_RuntimeBeatRef)) {
7681
+ let ref = value;
7682
+ if(ref.stack.length > 0) {
7683
+ let cyclic = false;
7684
+ let _g = 0;
7685
+ let _g1 = ref.stack;
7686
+ while(_g < _g1.length) {
7687
+ let captured = _g1[_g];
7688
+ ++_g;
7689
+ if(this._serializingScopes.indexOf(captured) != -1) {
7690
+ cyclic = true;
7691
+ break;
7692
+ }
7693
+ }
7694
+ if(!cyclic) {
7695
+ let insertions = this._saveInsertions != null ? this._saveInsertions : { };
7696
+ let _g = [];
7697
+ let _g1 = 0;
7698
+ let _g2 = ref.stack;
7699
+ while(_g1 < _g2.length) {
7700
+ let captured = _g2[_g1];
7701
+ ++_g1;
7702
+ _g.push(this.serializeScope(captured,insertions));
7703
+ }
7704
+ serializedRef.stack = _g;
7705
+ }
7706
+ }
7707
+ }
7708
+ return serializedRef;
7709
+ }
7572
7710
  return this.serializeFields(value);
7573
7711
  }
7574
7712
  resumeNode(node,scopeLevel,next) {
@@ -7579,6 +7717,9 @@ class loreline_Interpreter {
7579
7717
  case loreline_NAlternative:
7580
7718
  this.resumeAlternative(node,scopeLevel,next);
7581
7719
  break;
7720
+ case loreline_NBeatCall:
7721
+ this.resumeBeatCall(node,scopeLevel,next);
7722
+ break;
7582
7723
  case loreline_NBeatDecl:
7583
7724
  this.resumeBeatRun(node,scopeLevel,next);
7584
7725
  break;
@@ -7608,6 +7749,9 @@ class loreline_Interpreter {
7608
7749
  case loreline_NAlternative:
7609
7750
  this.evalAlternative(node,next);
7610
7751
  break;
7752
+ case loreline_NBeatCall:
7753
+ this.evalBeatCall(node,next);
7754
+ break;
7611
7755
  case loreline_NCall:
7612
7756
  if(!this.isBeatCall(node)) {
7613
7757
  this.evalCall(node,next);
@@ -7645,7 +7789,7 @@ class loreline_Interpreter {
7645
7789
  throw haxe_Exception.thrown(new loreline_RuntimeError("Failed to resolve head in scope when resuming through body",node.pos));
7646
7790
  }
7647
7791
  }
7648
- let currentInsertion = this.get_currentInsertion();
7792
+ let currentInsertion = this.insertionAtOrBelow(scopeLevel);
7649
7793
  let moveNext = null;
7650
7794
  let _gthis = this;
7651
7795
  moveNext = function() {
@@ -7688,13 +7832,23 @@ class loreline_Interpreter {
7688
7832
  if(scopeLevel + 1 < this.stack.length) {
7689
7833
  this.resumeNodeBody(option,scopeLevel + 1,option.body,next);
7690
7834
  } else {
7691
- this.evalNodeBody(currentScope.beat,option,option.body,null,next);
7835
+ this.evalNodeBody(currentScope.beat,option,option.body,null,null,null,next);
7692
7836
  }
7693
7837
  } else if(currentScope.insertion != null) {
7694
7838
  let insertionNode = currentScope.node;
7695
7839
  let insertion = currentScope.insertion;
7696
7840
  if(((insertionNode) instanceof loreline_NBeatDecl)) {
7697
7841
  let beat = insertionNode;
7842
+ let isRootPhase1 = true;
7843
+ let _g = 0;
7844
+ let _g1 = scopeLevel;
7845
+ while(_g < _g1) {
7846
+ let i = _g++;
7847
+ if(this.stack[i].insertion != null) {
7848
+ isRootPhase1 = false;
7849
+ break;
7850
+ }
7851
+ }
7698
7852
  this.resumeNodeBody(beat,scopeLevel,beat.body,function() {
7699
7853
  let options = insertion.parentPartialOptions != null ? insertion.parentPartialOptions : [];
7700
7854
  if(insertion.options != null) {
@@ -7711,7 +7865,7 @@ class loreline_Interpreter {
7711
7865
  let optionsDone = _gthis.wrapNext(function() {
7712
7866
  _gthis.presentChoice(choice,options,next);
7713
7867
  });
7714
- _gthis.evalChoiceOptionsAndInsertions(parentBeat,choice,options,optionsDone.cb,nextIndex);
7868
+ _gthis.evalChoiceOptionsAndInsertions(parentBeat,choice,options,optionsDone.cb,nextIndex,isRootPhase1);
7715
7869
  optionsDone.sync = false;
7716
7870
  });
7717
7871
  } else {
@@ -7759,32 +7913,20 @@ class loreline_Interpreter {
7759
7913
  throw haxe_Exception.thrown(new loreline_RuntimeError("Failed to resume alternative: head not found in any item",alt.pos));
7760
7914
  }
7761
7915
  resumeCall(call,scopeLevel,next) {
7762
- if(((call.target) instanceof loreline_NAccess)) {
7763
- let access = call.target;
7764
- if(access.target == null) {
7765
- let beatName = access.name;
7766
- let resolvedBeat = null;
7767
- let i = this.stack.length - 1;
7768
- while(i >= 0) {
7769
- let scope = this.stack[i];
7770
- let beatInScope = scope.beatByName(beatName);
7771
- if(beatInScope != null) {
7772
- resolvedBeat = beatInScope;
7773
- break;
7774
- }
7775
- --i;
7776
- }
7777
- if(resolvedBeat == null && Object.prototype.hasOwnProperty.call(this.topLevelBeats.h,beatName)) {
7778
- resolvedBeat = this.topLevelBeats.h[beatName];
7779
- }
7780
- if(resolvedBeat != null) {
7781
- this.resumeBeatRun(resolvedBeat,scopeLevel,next);
7782
- return;
7783
- }
7784
- }
7916
+ let resolvedRef = this.resolveBeatRefFromCall(call);
7917
+ if(resolvedRef != null) {
7918
+ this.resumeBeatRun(resolvedRef.beat,scopeLevel,next);
7919
+ return;
7785
7920
  }
7786
7921
  throw haxe_Exception.thrown(new loreline_RuntimeError("Cannot resume through a function call that is not at the bottom of the stack",call.pos));
7787
7922
  }
7923
+ resumeBeatCall(call,scopeLevel,next) {
7924
+ if(scopeLevel >= 0 && scopeLevel < this.stack.length && ((this.stack[scopeLevel].node) instanceof loreline_NBeatDecl)) {
7925
+ this.resumeBeatRun(this.stack[scopeLevel].node,scopeLevel,next);
7926
+ return;
7927
+ }
7928
+ throw haxe_Exception.thrown(new loreline_RuntimeError("Cannot resume through a beat call that is not at the bottom of the stack",call.pos));
7929
+ }
7788
7930
  restoreStack(savedStack,savedInsertions,restoredInsertions) {
7789
7931
  let result = [];
7790
7932
  if(restoredInsertions == null) {
@@ -7842,7 +7984,22 @@ class loreline_Interpreter {
7842
7984
  if(savedScope.insertion != null && savedInsertions != null) {
7843
7985
  insertion = this.restoreInsertion(savedScope.insertion,savedInsertions,restoredInsertions);
7844
7986
  }
7845
- return new loreline_RuntimeScope(null,beat,node,beats,state,head,insertion);
7987
+ let captured = null;
7988
+ if(savedScope.captured != null) {
7989
+ captured = [];
7990
+ let _g = 0;
7991
+ let _g1 = savedScope.captured;
7992
+ while(_g < _g1.length) {
7993
+ let savedCaptured = _g1[_g];
7994
+ ++_g;
7995
+ let capturedScope = this.restoreScopeItem(savedCaptured,savedInsertions,restoredInsertions);
7996
+ if(capturedScope == null) {
7997
+ return null;
7998
+ }
7999
+ captured.push(capturedScope);
8000
+ }
8001
+ }
8002
+ return new loreline_RuntimeScope(null,beat,node,beats,state,head,insertion,captured);
7846
8003
  }
7847
8004
  restoreInsertion(insertionId,savedInsertions,restoredInsertions) {
7848
8005
  if(restoredInsertions.h.hasOwnProperty(insertionId)) {
@@ -8065,6 +8222,31 @@ class loreline_Interpreter {
8065
8222
  }
8066
8223
  return arr;
8067
8224
  }
8225
+ if(Reflect.field(value,"type") == "$beatRef") {
8226
+ let savedRef = value;
8227
+ let beat = this.restoreBeat(savedRef.beat);
8228
+ if(beat == null) {
8229
+ return null;
8230
+ }
8231
+ let chain = [];
8232
+ if(savedRef.stack != null) {
8233
+ let savedInsertions = this._restoreSavedInsertions != null ? this._restoreSavedInsertions : { };
8234
+ let cache = this._restoreInsertionsCache != null ? this._restoreInsertionsCache : new haxe_ds_IntMap();
8235
+ let _g = 0;
8236
+ let _g1 = savedRef.stack;
8237
+ while(_g < _g1.length) {
8238
+ let savedScope = _g1[_g];
8239
+ ++_g;
8240
+ let scope = this.restoreScopeItem(savedScope,savedInsertions,cache);
8241
+ if(scope == null) {
8242
+ chain = [];
8243
+ break;
8244
+ }
8245
+ chain.push(scope);
8246
+ }
8247
+ }
8248
+ return new loreline_RuntimeBeatRef(beat,chain);
8249
+ }
8068
8250
  return this.restoreFields(null,value);
8069
8251
  }
8070
8252
  initializeTopLevelFunctions(functions) {
@@ -8081,7 +8263,7 @@ class loreline_Interpreter {
8081
8263
  let _g_key = key;
8082
8264
  let key1 = _g_key;
8083
8265
  let func = _g_value;
8084
- this.topLevelFunctions.h[key1] = func;
8266
+ this.registerTopLevelFunction(key1,func);
8085
8267
  }
8086
8268
  }
8087
8269
  let h = this.topLevelFunctions.h;
@@ -8106,6 +8288,15 @@ class loreline_Interpreter {
8106
8288
  }
8107
8289
  }
8108
8290
  }
8291
+ registerTopLevelFunction(key,func) {
8292
+ let userFunc = func;
8293
+ let _gthis = this;
8294
+ let this1 = this.topLevelFunctions;
8295
+ let value = Reflect.makeVarArgs(function(args) {
8296
+ return userFunc.apply(null,[_gthis,args]);
8297
+ });
8298
+ this1.h[key] = value;
8299
+ }
8109
8300
  initializeStringLiteralProcessors(processors) {
8110
8301
  let _gthis = this;
8111
8302
  this.stringLiteralProcessors.push(function(str) {
@@ -8273,13 +8464,52 @@ class loreline_Interpreter {
8273
8464
  }
8274
8465
  }
8275
8466
  }
8467
+ evaluateBeatArgs(beat,args,pos) {
8468
+ if(args == null || args.length == 0) {
8469
+ return null;
8470
+ }
8471
+ let numParams = beat.params != null ? beat.params.length : 0;
8472
+ if(args.length > numParams) {
8473
+ throw haxe_Exception.thrown(new loreline_RuntimeError("Beat " + beat.name + " expects at most " + numParams + " argument(s), got " + args.length,pos));
8474
+ }
8475
+ let _g = [];
8476
+ let _g1 = 0;
8477
+ while(_g1 < args.length) {
8478
+ let arg = args[_g1];
8479
+ ++_g1;
8480
+ _g.push(this.evaluateExpression(arg));
8481
+ }
8482
+ return _g;
8483
+ }
8484
+ seedBeatParams(scope,beat,values) {
8485
+ let params = beat.params;
8486
+ if(params == null || params.length == 0) {
8487
+ return;
8488
+ }
8489
+ if(scope.state == null) {
8490
+ scope.state = new loreline_RuntimeState(this,beat,null,null);
8491
+ }
8492
+ let _g = 0;
8493
+ let _g1 = params.length;
8494
+ while(_g < _g1) {
8495
+ let i = _g++;
8496
+ let param = params[i];
8497
+ let value = null;
8498
+ if(values != null && i < values.length) {
8499
+ value = values[i];
8500
+ } else if(param.defaultValue != null) {
8501
+ value = this.evaluateExpression(param.defaultValue);
8502
+ }
8503
+ loreline_Objects.setField(this,scope.state.fields,param.name,value);
8504
+ }
8505
+ }
8276
8506
  finish() {
8277
8507
  this.finishTrigger = null;
8278
8508
  if(this.handleFinish != null) {
8279
8509
  this.handleFinish(this);
8280
8510
  }
8281
8511
  }
8282
- transitionToBeat(beat) {
8512
+ transitionToBeat(beat,argValues,capturedChain) {
8283
8513
  while(this.pop()) {
8284
8514
  }
8285
8515
  this.nextScopeId = 1;
@@ -8289,7 +8519,7 @@ class loreline_Interpreter {
8289
8519
  this._choiceEvalEnabled.length = 0;
8290
8520
  let done = this.wrapNext($bind(this,this.finish));
8291
8521
  this.finishTrigger = done;
8292
- this.evalBeatRun(beat,done.cb);
8522
+ this.evalBeatRun(beat,done.cb,argValues,capturedChain);
8293
8523
  done.sync = false;
8294
8524
  }
8295
8525
  evalNode(node,next) {
@@ -8300,6 +8530,9 @@ class loreline_Interpreter {
8300
8530
  case loreline_NAssign:
8301
8531
  this.evalAssignment(node,next);
8302
8532
  break;
8533
+ case loreline_NBeatCall:
8534
+ this.evalBeatCall(node,next);
8535
+ break;
8303
8536
  case loreline_NBeatDecl:
8304
8537
  this.evalBeatDecl(node,next);
8305
8538
  break;
@@ -8341,8 +8574,14 @@ class loreline_Interpreter {
8341
8574
  this.get_currentScope().beats.push(beat);
8342
8575
  next();
8343
8576
  }
8344
- evalNodeBody(beat,node,body,insertion,next) {
8345
- this.push(new loreline_RuntimeScope(null,beat,node,null,null,null,insertion));
8577
+ evalNodeBody(beat,node,body,insertion,argValues,capturedChain,next) {
8578
+ this.push(new loreline_RuntimeScope(null,beat,node,null,null,null,insertion,null));
8579
+ if(node == beat && beat != null && beat.params != null) {
8580
+ this.seedBeatParams(this.get_currentScope(),beat,argValues);
8581
+ }
8582
+ if(node == beat && beat != null && capturedChain != null && capturedChain.length > 0) {
8583
+ this.get_currentScope().captured = capturedChain;
8584
+ }
8346
8585
  let index = 0;
8347
8586
  let moveNext = null;
8348
8587
  let currentInsertion = this.get_currentInsertion();
@@ -8365,9 +8604,9 @@ class loreline_Interpreter {
8365
8604
  };
8366
8605
  moveNext();
8367
8606
  }
8368
- evalBeatRun(beat,next) {
8607
+ evalBeatRun(beat,next,argValues,capturedChain) {
8369
8608
  this.incrementBeatVisitCount(beat);
8370
- this.evalNodeBody(beat,beat,beat.body,null,next);
8609
+ this.evalNodeBody(beat,beat,beat.body,null,argValues,capturedChain,next);
8371
8610
  }
8372
8611
  evalStateDecl(state,next) {
8373
8612
  this.initializeState(state,this.get_currentScope());
@@ -8412,7 +8651,7 @@ class loreline_Interpreter {
8412
8651
  let optionsDone = this.wrapNext(function() {
8413
8652
  _gthis.presentChoice(choice,options,next);
8414
8653
  });
8415
- this.evalChoiceOptionsAndInsertions(this.get_currentScope().beat,choice,options,optionsDone.cb);
8654
+ this.evalChoiceOptionsAndInsertions(this.get_currentScope().beat,choice,options,optionsDone.cb,null,this.get_currentInsertion() == null);
8416
8655
  optionsDone.sync = false;
8417
8656
  }
8418
8657
  presentChoice(choice,options,next) {
@@ -8464,7 +8703,7 @@ class loreline_Interpreter {
8464
8703
  _gthis.stack.push(scope);
8465
8704
  }
8466
8705
  let lastScope = _gthis.stack[_gthis.stack.length - 1];
8467
- _gthis.push(new loreline_RuntimeScope(null,lastScope.beat,_gthis.lens.getParentNode(option.node),null,null,option.node,null));
8706
+ _gthis.push(new loreline_RuntimeScope(null,lastScope.beat,_gthis.lens.getParentNode(option.node),null,null,option.node,null,null));
8468
8707
  _gthis.resumeFromLevel(scopeLevel,wrappedNext);
8469
8708
  } else {
8470
8709
  _gthis.evalChoiceOption(option.node,wrappedNext);
@@ -8480,10 +8719,22 @@ class loreline_Interpreter {
8480
8719
  });
8481
8720
  choiceCallback.sync = false;
8482
8721
  }
8483
- evalChoiceOptionsAndInsertions(beat,choice,result,next,startIndex) {
8722
+ evalChoiceOptionsAndInsertions(beat,choice,result,next,startIndex,isChoiceRoot) {
8723
+ if(isChoiceRoot == null) {
8724
+ isChoiceRoot = true;
8725
+ }
8484
8726
  let options = choice.options;
8485
- this._choiceEvalTexts.length = 0;
8486
- this._choiceEvalEnabled.length = 0;
8727
+ if(isChoiceRoot) {
8728
+ this._choiceEvalTexts.length = 0;
8729
+ this._choiceEvalEnabled.length = 0;
8730
+ let _g = 0;
8731
+ while(_g < result.length) {
8732
+ let opt = result[_g];
8733
+ ++_g;
8734
+ this._choiceEvalTexts.push(opt.text);
8735
+ this._choiceEvalEnabled.push(opt.enabled);
8736
+ }
8737
+ }
8487
8738
  let index = startIndex != null ? startIndex : 0;
8488
8739
  let moveNext = null;
8489
8740
  let insertion = null;
@@ -8496,8 +8747,6 @@ class loreline_Interpreter {
8496
8747
  let i = _g++;
8497
8748
  let opt = insertion.options[i];
8498
8749
  result.push(opt);
8499
- _gthis._choiceEvalTexts.push(opt.text);
8500
- _gthis._choiceEvalEnabled.push(opt.enabled);
8501
8750
  }
8502
8751
  insertion = null;
8503
8752
  }
@@ -8536,36 +8785,36 @@ class loreline_Interpreter {
8536
8785
  moveNext();
8537
8786
  }
8538
8787
  evalInsertion(insertion,next) {
8539
- let beatName = insertion.origin.target;
8540
- let resolvedBeat = null;
8541
- let i = this.stack.length - 1;
8542
- while(i >= 0) {
8543
- let scope = this.stack[i];
8544
- let beatInScope = scope.beatByName(beatName);
8545
- if(beatInScope != null) {
8546
- resolvedBeat = beatInScope;
8547
- break;
8548
- }
8549
- --i;
8550
- }
8551
- if(resolvedBeat == null) {
8552
- if(Object.prototype.hasOwnProperty.call(this.topLevelBeats.h,beatName)) {
8553
- resolvedBeat = this.topLevelBeats.h[beatName];
8788
+ let origin = insertion.origin;
8789
+ let resolvedRef = null;
8790
+ if(origin.targetExpr != null) {
8791
+ let value = this.evaluateExpression(origin.targetExpr);
8792
+ resolvedRef = this.resolveDynamicBeatTarget(value,origin);
8793
+ } else {
8794
+ let beatName = origin.target;
8795
+ resolvedRef = this.resolveBeatRefFromNode(beatName,origin);
8796
+ if(resolvedRef == null) {
8797
+ throw haxe_Exception.thrown(this.beatNotFoundError(beatName,origin));
8554
8798
  }
8555
8799
  }
8556
- if(resolvedBeat == null) {
8557
- throw haxe_Exception.thrown(new loreline_RuntimeError("Beat " + beatName + " not found",this.script.pos));
8558
- }
8559
- this.evalNodeBody(resolvedBeat,resolvedBeat,resolvedBeat.body,insertion,next);
8800
+ let resolvedBeat = resolvedRef.beat;
8801
+ let argValues = this.evaluateBeatArgs(resolvedBeat,origin.args,origin.pos);
8802
+ this.evalNodeBody(resolvedBeat,resolvedBeat,resolvedBeat.body,insertion,argValues,resolvedRef.stack.length > 0 ? resolvedRef.stack : null,next);
8803
+ }
8804
+ evalBeatCall(call,next) {
8805
+ let value = this.evaluateExpression(call.targetExpr);
8806
+ let resolvedRef = this.resolveDynamicBeatTarget(value,call);
8807
+ let argValues = this.evaluateBeatArgs(resolvedRef.beat,call.args,call.pos);
8808
+ this.evalBeatRun(resolvedRef.beat,next,argValues,resolvedRef.stack.length > 0 ? resolvedRef.stack : null);
8560
8809
  }
8561
8810
  evalChoiceOption(option,next) {
8562
- this.evalNodeBody(this.get_currentScope().beat,option,option.body,null,next);
8811
+ this.evalNodeBody(this.get_currentScope().beat,option,option.body,null,null,null,next);
8563
8812
  }
8564
8813
  evalIf(ifStmt,next) {
8565
8814
  let isTrue = this.evaluateCondition(ifStmt.condition);
8566
8815
  let branch = isTrue ? ifStmt.thenBranch : ifStmt.elseBranch;
8567
8816
  if(branch != null && branch.body.length > 0) {
8568
- this.evalNodeBody(this.get_currentScope().beat,branch,branch.body,null,next);
8817
+ this.evalNodeBody(this.get_currentScope().beat,branch,branch.body,null,null,null,next);
8569
8818
  } else {
8570
8819
  next();
8571
8820
  }
@@ -8581,14 +8830,14 @@ class loreline_Interpreter {
8581
8830
  let idx = visitCount < alt.items.length ? visitCount : alt.items.length - 1;
8582
8831
  this.setAlternativeVisitCount(alt,visitCount + 1);
8583
8832
  let item = alt.items[idx];
8584
- this.evalNodeBody(this.get_currentScope().beat,item,item.body,null,next);
8833
+ this.evalNodeBody(this.get_currentScope().beat,item,item.body,null,null,null,next);
8585
8834
  break;
8586
8835
  case 1:
8587
8836
  let visitCount1 = this.getAlternativeVisitCount(alt);
8588
8837
  let idx1 = visitCount1 % alt.items.length;
8589
8838
  this.setAlternativeVisitCount(alt,visitCount1 + 1);
8590
8839
  let item1 = alt.items[idx1];
8591
- this.evalNodeBody(this.get_currentScope().beat,item1,item1.body,null,next);
8840
+ this.evalNodeBody(this.get_currentScope().beat,item1,item1.body,null,null,null,next);
8592
8841
  break;
8593
8842
  case 2:
8594
8843
  let visitCount2 = this.getAlternativeVisitCount(alt);
@@ -8598,12 +8847,12 @@ class loreline_Interpreter {
8598
8847
  }
8599
8848
  this.setAlternativeVisitCount(alt,visitCount2 + 1);
8600
8849
  let item2 = alt.items[visitCount2];
8601
- this.evalNodeBody(this.get_currentScope().beat,item2,item2.body,null,next);
8850
+ this.evalNodeBody(this.get_currentScope().beat,item2,item2.body,null,null,null,next);
8602
8851
  break;
8603
8852
  case 3:
8604
8853
  let idx2 = this.builtins.random(0,alt.items.length - 1);
8605
8854
  let item3 = alt.items[idx2];
8606
- this.evalNodeBody(this.get_currentScope().beat,item3,item3.body,null,next);
8855
+ this.evalNodeBody(this.get_currentScope().beat,item3,item3.body,null,null,null,next);
8607
8856
  break;
8608
8857
  case 4:
8609
8858
  let _g = [];
@@ -8633,7 +8882,7 @@ class loreline_Interpreter {
8633
8882
  }
8634
8883
  let item = alt.items[indices[idx]];
8635
8884
  let _gthis = this;
8636
- this.evalNodeBody(this.get_currentScope().beat,item,item.body,null,function() {
8885
+ this.evalNodeBody(this.get_currentScope().beat,item,item.body,null,null,null,function() {
8637
8886
  _gthis.evalShuffledItems(alt,indices,idx + 1,next);
8638
8887
  });
8639
8888
  }
@@ -8810,7 +9059,16 @@ class loreline_Interpreter {
8810
9059
  scopeLevel = -1;
8811
9060
  }
8812
9061
  if(((node) instanceof loreline_NCall)) {
8813
- return this.resolveBeatFromCall(node,scopeLevel) != null;
9062
+ return this.resolveBeatRefFromCall(node) != null;
9063
+ }
9064
+ return false;
9065
+ }
9066
+ isDynamicCallForm(call) {
9067
+ if(((call.target) instanceof loreline_NAccess)) {
9068
+ let access = call.target;
9069
+ if(access.target == null && access.name == "call") {
9070
+ return !this.resolvesExistingBinding("call");
9071
+ }
8814
9072
  }
8815
9073
  return false;
8816
9074
  }
@@ -8818,65 +9076,171 @@ class loreline_Interpreter {
8818
9076
  if(scopeLevel == null) {
8819
9077
  scopeLevel = -1;
8820
9078
  }
8821
- let i = scopeLevel == -1 ? this.stack.length - 1 : scopeLevel;
8822
- while(i >= 0) {
8823
- let b = this.stack[i].beatByName(name);
9079
+ let result = null;
9080
+ this.eachResolutionScope(scopeLevel,function(scope) {
9081
+ let b = scope.beatByName(name);
8824
9082
  if(b != null) {
8825
- return b;
9083
+ result = b;
9084
+ return true;
8826
9085
  }
8827
- --i;
9086
+ return false;
9087
+ });
9088
+ if(result != null) {
9089
+ return result;
8828
9090
  }
8829
9091
  return this.topLevelBeats.h[name];
8830
9092
  }
8831
- resolveBeatFromCall(call,scopeLevel) {
8832
- if(scopeLevel == null) {
8833
- scopeLevel = -1;
9093
+ resolveBeatRefByName(name) {
9094
+ let result = null;
9095
+ let walk = null;
9096
+ walk = function(scopes,startIndex) {
9097
+ let i = startIndex;
9098
+ while(i >= 0) {
9099
+ let scope = scopes[i];
9100
+ let b = scope.beatByName(name);
9101
+ if(b != null) {
9102
+ result = new loreline_RuntimeBeatRef(b,scopes.slice(0,i + 1));
9103
+ return;
9104
+ }
9105
+ if(scope.captured != null) {
9106
+ walk(scope.captured,scope.captured.length - 1);
9107
+ return;
9108
+ }
9109
+ --i;
9110
+ }
9111
+ };
9112
+ walk(this.stack,this.stack.length - 1);
9113
+ if(result != null) {
9114
+ return result;
9115
+ }
9116
+ let topLevel = this.topLevelBeats.h[name];
9117
+ if(topLevel != null) {
9118
+ return new loreline_RuntimeBeatRef(topLevel,[]);
9119
+ }
9120
+ return null;
9121
+ }
9122
+ resolveBeatRefFromNode(name,node) {
9123
+ if(node == null) {
9124
+ return this.resolveBeatRefByName(name);
9125
+ }
9126
+ let lexical = this.lens.findBeatByNameFromNode(name,node);
9127
+ if(lexical == null) {
9128
+ return null;
9129
+ }
9130
+ return new loreline_RuntimeBeatRef(lexical,this.captureChainForBeat(lexical));
9131
+ }
9132
+ captureChainForBeat(beat) {
9133
+ let parentBeat = this.lens.getFirstParentOfType(beat,loreline_NBeatDecl);
9134
+ if(parentBeat == null) {
9135
+ return [];
9136
+ }
9137
+ let result = null;
9138
+ let walk = null;
9139
+ walk = function(scopes,startIndex) {
9140
+ let i = startIndex;
9141
+ let parentMatch = -1;
9142
+ while(i >= 0) {
9143
+ let scope = scopes[i];
9144
+ if(scope.beats != null && scope.beats.indexOf(beat) != -1) {
9145
+ result = scopes.slice(0,i + 1);
9146
+ return;
9147
+ }
9148
+ if(parentMatch == -1 && scope.beat == parentBeat) {
9149
+ parentMatch = i;
9150
+ }
9151
+ if(scope.captured != null) {
9152
+ walk(scope.captured,scope.captured.length - 1);
9153
+ if(result == null && parentMatch != -1) {
9154
+ result = scopes.slice(0,parentMatch + 1);
9155
+ }
9156
+ return;
9157
+ }
9158
+ --i;
9159
+ }
9160
+ if(result == null && parentMatch != -1) {
9161
+ result = scopes.slice(0,parentMatch + 1);
9162
+ }
9163
+ };
9164
+ walk(this.stack,this.stack.length - 1);
9165
+ if(result != null) {
9166
+ return result;
9167
+ } else {
9168
+ return [];
8834
9169
  }
9170
+ }
9171
+ resolveDynamicBeatTarget(value,node) {
9172
+ if(((value) instanceof loreline_RuntimeBeatRef)) {
9173
+ return value;
9174
+ }
9175
+ if(((value) instanceof loreline_NBeatDecl)) {
9176
+ return new loreline_RuntimeBeatRef(value,[]);
9177
+ }
9178
+ if(typeof(value) == "string") {
9179
+ let name = value;
9180
+ let resolved = this.resolveBeatRefFromNode(name,node);
9181
+ if(resolved == null) {
9182
+ throw haxe_Exception.thrown(this.beatNotFoundError(name,node));
9183
+ }
9184
+ return resolved;
9185
+ }
9186
+ throw haxe_Exception.thrown(new loreline_RuntimeError("Invalid dynamic beat target: " + this.valueToString(value),node.pos));
9187
+ }
9188
+ beatNotFoundError(name,node) {
9189
+ let pos = node != null ? node.pos : this.script.pos;
9190
+ let _g = 0;
9191
+ let _g1 = this.lens.getNodesOfType(loreline_NBeatDecl,true);
9192
+ while(_g < _g1.length) {
9193
+ let decl = _g1[_g];
9194
+ ++_g;
9195
+ if(decl.name == name) {
9196
+ return new loreline_RuntimeError("Beat " + name + " is not visible from this scope. Store a reference (ref = " + name + ") while it is in scope to use it from elsewhere.",pos);
9197
+ }
9198
+ }
9199
+ return new loreline_RuntimeError("Beat " + name + " not found",pos);
9200
+ }
9201
+ resolveBeatRefFromCall(call) {
8835
9202
  if(((call.target) instanceof loreline_NAccess)) {
8836
9203
  let access = call.target;
8837
9204
  if(access.target == null) {
8838
- let resolvedBeat = this.resolveBeatByName(access.name,scopeLevel);
8839
- if(resolvedBeat != null) {
8840
- return resolvedBeat;
8841
- }
9205
+ return this.resolveBeatRefFromNode(access.name,access);
8842
9206
  }
8843
9207
  }
8844
9208
  return null;
8845
9209
  }
8846
9210
  evalCall(call,next) {
8847
- let resolvedBeat = this.resolveBeatFromCall(call);
8848
- if(resolvedBeat != null) {
8849
- this.evalBeatRun(resolvedBeat,next);
9211
+ let resolvedRef = this.resolveBeatRefFromCall(call);
9212
+ if(resolvedRef != null) {
9213
+ let argValues = this.evaluateBeatArgs(resolvedRef.beat,call.args,call.pos);
9214
+ this.evalBeatRun(resolvedRef.beat,next,argValues,resolvedRef.stack.length > 0 ? resolvedRef.stack : null);
8850
9215
  return;
8851
9216
  }
8852
9217
  this.evaluateFunctionCall(call,next);
8853
9218
  }
8854
9219
  evalTransition(transition) {
8855
- let beatName = transition.target;
8856
- if(beatName == ".") {
8857
- this.finish();
8858
- return;
8859
- }
8860
- let resolvedBeat = null;
8861
- let i = this.stack.length - 1;
8862
- while(i >= 0) {
8863
- let scope = this.stack[i];
8864
- let beatInScope = scope.beatByName(beatName);
8865
- if(beatInScope != null) {
8866
- resolvedBeat = beatInScope;
8867
- break;
9220
+ let resolvedRef = null;
9221
+ if(transition.targetExpr != null) {
9222
+ let value = this.evaluateExpression(transition.targetExpr);
9223
+ if(typeof(value) == "string" && value == ".") {
9224
+ if(transition.args != null && transition.args.length > 0) {
9225
+ throw haxe_Exception.thrown(new loreline_RuntimeError("Cannot pass arguments when ending the script",transition.pos));
9226
+ }
9227
+ this.finish();
9228
+ return;
8868
9229
  }
8869
- --i;
8870
- }
8871
- if(resolvedBeat == null) {
8872
- if(Object.prototype.hasOwnProperty.call(this.topLevelBeats.h,beatName)) {
8873
- resolvedBeat = this.topLevelBeats.h[beatName];
9230
+ resolvedRef = this.resolveDynamicBeatTarget(value,transition);
9231
+ } else {
9232
+ let beatName = transition.target;
9233
+ if(beatName == ".") {
9234
+ this.finish();
9235
+ return;
9236
+ }
9237
+ resolvedRef = this.resolveBeatRefFromNode(beatName,transition);
9238
+ if(resolvedRef == null) {
9239
+ throw haxe_Exception.thrown(this.beatNotFoundError(beatName,transition));
8874
9240
  }
8875
9241
  }
8876
- if(resolvedBeat == null) {
8877
- throw haxe_Exception.thrown(new loreline_RuntimeError("Beat " + beatName + " not found",this.script.pos));
8878
- }
8879
- this.transitionToBeat(resolvedBeat);
9242
+ let argValues = this.evaluateBeatArgs(resolvedRef.beat,transition.args,transition.pos);
9243
+ this.transitionToBeat(resolvedRef.beat,argValues,resolvedRef.stack.length > 0 ? resolvedRef.stack : null);
8880
9244
  }
8881
9245
  getTranslatedString(node,str) {
8882
9246
  if(this.translations != null) {
@@ -8956,7 +9320,8 @@ class loreline_Interpreter {
8956
9320
  if(!keepIndents) {
8957
9321
  text = this.stripStringIndent(text);
8958
9322
  }
8959
- let len = text.length;
9323
+ let chars = text;
9324
+ let len = chars.length;
8960
9325
  if(len > 0) {
8961
9326
  keepWhitespace = true;
8962
9327
  }
@@ -8967,7 +9332,7 @@ class loreline_Interpreter {
8967
9332
  let _g3 = len;
8968
9333
  while(_g1 < _g3) {
8969
9334
  let i = _g1++;
8970
- let c = HxOverrides.cca(text,i);
9335
+ let c = HxOverrides.cca(chars,i);
8971
9336
  let c1 = c == null ? -1 : c;
8972
9337
  if(escaped) {
8973
9338
  if(c1 == 110) {
@@ -9281,15 +9646,16 @@ class loreline_Interpreter {
9281
9646
  return content;
9282
9647
  }
9283
9648
  stripStringComments(content) {
9649
+ let chars = content;
9284
9650
  let result_b = "";
9285
- let len = content.length;
9651
+ let len = chars.length;
9286
9652
  let i = 0;
9287
9653
  while(i < len) {
9288
- let c = HxOverrides.cca(content,i);
9654
+ let c = HxOverrides.cca(chars,i);
9289
9655
  let c1 = c == null ? -1 : c;
9290
9656
  let tmp;
9291
9657
  if(c1 == 47 && i + 1 < len) {
9292
- let c = HxOverrides.cca(content,i + 1);
9658
+ let c = HxOverrides.cca(chars,i + 1);
9293
9659
  tmp = (c == null ? -1 : c) == 47;
9294
9660
  } else {
9295
9661
  tmp = false;
@@ -9298,7 +9664,7 @@ class loreline_Interpreter {
9298
9664
  while(true) {
9299
9665
  let tmp;
9300
9666
  if(i < len) {
9301
- let c = HxOverrides.cca(content,i);
9667
+ let c = HxOverrides.cca(chars,i);
9302
9668
  tmp = (c == null ? -1 : c) != 10;
9303
9669
  } else {
9304
9670
  tmp = false;
@@ -9312,7 +9678,7 @@ class loreline_Interpreter {
9312
9678
  }
9313
9679
  let tmp1;
9314
9680
  if(c1 == 47 && i + 1 < len) {
9315
- let c = HxOverrides.cca(content,i + 1);
9681
+ let c = HxOverrides.cca(chars,i + 1);
9316
9682
  tmp1 = (c == null ? -1 : c) == 42;
9317
9683
  } else {
9318
9684
  tmp1 = false;
@@ -9320,7 +9686,7 @@ class loreline_Interpreter {
9320
9686
  if(tmp1) {
9321
9687
  let hadSpaceBefore;
9322
9688
  if(i > 0) {
9323
- let c = HxOverrides.cca(content,i - 1);
9689
+ let c = HxOverrides.cca(chars,i - 1);
9324
9690
  hadSpaceBefore = (c == null ? -1 : c) == 32;
9325
9691
  } else {
9326
9692
  hadSpaceBefore = false;
@@ -9330,9 +9696,9 @@ class loreline_Interpreter {
9330
9696
  let tmp;
9331
9697
  if(i + 1 < len) {
9332
9698
  let tmp1;
9333
- let c = HxOverrides.cca(content,i);
9699
+ let c = HxOverrides.cca(chars,i);
9334
9700
  if((c == null ? -1 : c) == 42) {
9335
- let c = HxOverrides.cca(content,i + 1);
9701
+ let c = HxOverrides.cca(chars,i + 1);
9336
9702
  tmp1 = (c == null ? -1 : c) == 47;
9337
9703
  } else {
9338
9704
  tmp1 = false;
@@ -9349,7 +9715,7 @@ class loreline_Interpreter {
9349
9715
  i += 2;
9350
9716
  let hasSpaceAfter;
9351
9717
  if(i < len) {
9352
- let c = HxOverrides.cca(content,i);
9718
+ let c = HxOverrides.cca(chars,i);
9353
9719
  hasSpaceAfter = (c == null ? -1 : c) == 32;
9354
9720
  } else {
9355
9721
  hasSpaceAfter = false;
@@ -9373,8 +9739,8 @@ class loreline_Interpreter {
9373
9739
  return value == true;
9374
9740
  } else if(typeof(value) == "string") {
9375
9741
  return value.length > 0;
9376
- } else if(((value) instanceof Array)) {
9377
- return value.length > 0;
9742
+ } else if(loreline_Arrays.isArray(value)) {
9743
+ return loreline_Arrays.arrayLength(value) > 0;
9378
9744
  } else if(typeof(value) == "number" && ((value | 0) === value)) {
9379
9745
  return value != 0;
9380
9746
  } else if(typeof(value) == "number") {
@@ -9383,10 +9749,104 @@ class loreline_Interpreter {
9383
9749
  return value != null;
9384
9750
  }
9385
9751
  }
9752
+ callFunctionValue(fn,args,pos,next) {
9753
+ try {
9754
+ let result = fn.apply(null,args);
9755
+ if(result != null && ((result) instanceof loreline_Async)) {
9756
+ if(next == null) {
9757
+ throw haxe_Exception.thrown(new loreline_RuntimeError("Cannot call async function in expression",pos));
9758
+ } else {
9759
+ let asyncResult = result;
9760
+ asyncResult.func(next);
9761
+ }
9762
+ } else if(next != null) {
9763
+ next();
9764
+ }
9765
+ return result;
9766
+ } catch( _g ) {
9767
+ let e = haxe_Exception.caught(_g).unwrap();
9768
+ if(((e) instanceof loreline_lorscript_Error)) {
9769
+ let lorscriptErr = e;
9770
+ throw haxe_Exception.thrown(new loreline_RuntimeError("Error when evaluating function (" + lorscriptErr.pmin + "-" + lorscriptErr.pmax + "): " + Std.string(lorscriptErr.e),pos));
9771
+ }
9772
+ throw haxe_Exception.thrown(new loreline_RuntimeError("Error when calling function: " + Std.string(e),pos));
9773
+ }
9774
+ }
9775
+ resolvesExistingBinding(name) {
9776
+ let found = false;
9777
+ let _gthis = this;
9778
+ this.eachResolutionScope(-1,function(scope) {
9779
+ if(scope.state != null && loreline_Objects.fieldExists(_gthis,scope.state.fields,name)) {
9780
+ found = true;
9781
+ return true;
9782
+ }
9783
+ if(scope.node != null) {
9784
+ let key = scope.node.id.thisVal;
9785
+ let stateInNode = _gthis.nodeStates.map._get(key.high,key.low);
9786
+ if(stateInNode != null && loreline_Objects.fieldExists(_gthis,stateInNode.fields,name)) {
9787
+ found = true;
9788
+ return true;
9789
+ }
9790
+ }
9791
+ return false;
9792
+ });
9793
+ if(found) {
9794
+ return true;
9795
+ }
9796
+ if(loreline_Objects.fieldExists(this,this.topLevelState.fields,name)) {
9797
+ return true;
9798
+ }
9799
+ if(Object.prototype.hasOwnProperty.call(this.topLevelCharacters.h,name)) {
9800
+ return true;
9801
+ }
9802
+ if(Object.prototype.hasOwnProperty.call(this.topLevelFunctions.h,name)) {
9803
+ return true;
9804
+ }
9805
+ if(this.resolveBeatByName(name) != null) {
9806
+ return true;
9807
+ }
9808
+ return false;
9809
+ }
9810
+ evaluateDynamicCall(call,next) {
9811
+ if(call.args.length == 0) {
9812
+ throw haxe_Exception.thrown(new loreline_RuntimeError("call() requires a target argument",call.pos));
9813
+ }
9814
+ let targetValue = this.evaluateExpression(call.args[0]);
9815
+ if(loreline_RuntimeBeatRef.beatOf(targetValue) != null) {
9816
+ throw haxe_Exception.thrown(new loreline_RuntimeError("call() can only call functions. Use beat(...) to call a beat.",call.pos));
9817
+ }
9818
+ let fn = null;
9819
+ if(Reflect.isFunction(targetValue)) {
9820
+ fn = targetValue;
9821
+ } else if(typeof(targetValue) == "string") {
9822
+ let name = targetValue;
9823
+ if(this.resolveBeatByName(name) != null) {
9824
+ throw haxe_Exception.thrown(new loreline_RuntimeError("call() can only call functions. Use beat(...) to call a beat.",call.pos));
9825
+ }
9826
+ if(Object.prototype.hasOwnProperty.call(this.topLevelFunctions.h,name)) {
9827
+ fn = this.topLevelFunctions.h[name];
9828
+ }
9829
+ }
9830
+ if(fn != null) {
9831
+ let _g = [];
9832
+ let _g1 = 1;
9833
+ let _g2 = call.args.length;
9834
+ while(_g1 < _g2) {
9835
+ let i = _g1++;
9836
+ _g.push(this.evaluateExpression(call.args[i]));
9837
+ }
9838
+ let values = _g;
9839
+ return this.callFunctionValue(fn,values,call.pos,next);
9840
+ }
9841
+ throw haxe_Exception.thrown(new loreline_RuntimeError("call() target is not a function: " + this.valueToString(targetValue),call.pos));
9842
+ }
9386
9843
  evaluateFunctionCall(call,next) {
9387
9844
  if(((call.target) instanceof loreline_NAccess)) {
9388
9845
  let access = call.target;
9389
9846
  if(access.target == null) {
9847
+ if(access.name == "call" && !this.resolvesExistingBinding("call")) {
9848
+ return this.evaluateDynamicCall(call,next);
9849
+ }
9390
9850
  let target = this.evaluateExpression(call.target);
9391
9851
  if(target != null) {
9392
9852
  if(Reflect.isFunction(target)) {
@@ -9399,37 +9859,18 @@ class loreline_Interpreter {
9399
9859
  _g.push(this.evaluateExpression(arg));
9400
9860
  }
9401
9861
  let args = _g;
9402
- try {
9403
- let result = target.apply(null,args);
9404
- if(result != null && ((result) instanceof loreline_Async)) {
9405
- if(next == null) {
9406
- throw haxe_Exception.thrown(new loreline_RuntimeError("Cannot call async function in expression",call.pos));
9407
- } else {
9408
- let asyncResult = result;
9409
- asyncResult.func(next);
9410
- }
9411
- } else if(next != null) {
9412
- next();
9413
- }
9414
- return result;
9415
- } catch( _g ) {
9416
- let e = haxe_Exception.caught(_g).unwrap();
9417
- if(((e) instanceof loreline_lorscript_Error)) {
9418
- let lorscriptErr = e;
9419
- throw haxe_Exception.thrown(new loreline_RuntimeError("Error when evaluating function (" + lorscriptErr.pmin + "-" + lorscriptErr.pmax + "): " + Std.string(lorscriptErr.e),call.pos));
9420
- }
9421
- throw haxe_Exception.thrown(new loreline_RuntimeError("Error when calling function: " + Std.string(e),call.pos));
9422
- }
9862
+ return this.callFunctionValue(target,args,call.pos,next);
9423
9863
  }
9424
9864
  }
9425
9865
  } else {
9426
9866
  let obj = this.evaluateExpression(access.target);
9427
9867
  let helper = null;
9868
+ let objBeat = loreline_RuntimeBeatRef.beatOf(obj);
9428
9869
  if(typeof(obj) == "string") {
9429
9870
  helper = loreline_Objects.getStringHelper(this,access.name);
9430
9871
  } else if(loreline_Arrays.isArray(obj)) {
9431
9872
  helper = loreline_Objects.getArrayHelper(this,access.name);
9432
- } else if(((obj) instanceof loreline_NBeatDecl)) {
9873
+ } else if(objBeat != null) {
9433
9874
  helper = loreline_Objects.getBeatHelper(this,access.name);
9434
9875
  } else if(loreline_Objects.isFields(obj)) {
9435
9876
  helper = loreline_Objects.getMapHelper(this,access.name);
@@ -9444,7 +9885,7 @@ class loreline_Interpreter {
9444
9885
  _g.push(this.evaluateExpression(arg));
9445
9886
  }
9446
9887
  let args = _g;
9447
- args.splice(0,0,obj);
9888
+ args.splice(0,0,objBeat != null ? objBeat : obj);
9448
9889
  let result = helper.apply(null,args);
9449
9890
  if(result != null && ((result) instanceof loreline_Async)) {
9450
9891
  if(next == null) {
@@ -9506,14 +9947,12 @@ class loreline_Interpreter {
9506
9947
  return _g;
9507
9948
  }
9508
9949
  evaluateObjectLiteral(expr) {
9509
- let obj = new haxe_ds_StringMap();
9950
+ let obj = { };
9510
9951
  let _g = 0;
9511
9952
  while(_g < expr.length) {
9512
9953
  let field = expr[_g];
9513
9954
  ++_g;
9514
- let key = field.name;
9515
- let value = this.evaluateExpression(field.value);
9516
- obj.h[key] = value;
9955
+ obj[field.name] = this.evaluateExpression(field.value);
9517
9956
  }
9518
9957
  return obj;
9519
9958
  }
@@ -9612,13 +10051,8 @@ class loreline_Interpreter {
9612
10051
  } else {
9613
10052
  return true;
9614
10053
  }
9615
- } else if(((operand) instanceof Array)) {
9616
- let v = operand;
9617
- if(v != null) {
9618
- return v.length == 0;
9619
- } else {
9620
- return true;
9621
- }
10054
+ } else if(loreline_Arrays.isArray(operand)) {
10055
+ return loreline_Arrays.arrayLength(operand) == 0;
9622
10056
  } else if(typeof(operand) == "number" && ((operand | 0) === operand)) {
9623
10057
  let v = operand;
9624
10058
  return v == 0;
@@ -9673,8 +10107,8 @@ class loreline_Interpreter {
9673
10107
  break;
9674
10108
  case 4:
9675
10109
  let pos4 = access.pos;
9676
- let beat = access.beat;
9677
- return beat;
10110
+ let ref = access.ref;
10111
+ return ref;
9678
10112
  }
9679
10113
  }
9680
10114
  writeAccess(access,value) {
@@ -9704,8 +10138,8 @@ class loreline_Interpreter {
9704
10138
  throw haxe_Exception.thrown(new loreline_RuntimeError("Cannot overwrite function: " + name2,pos3));
9705
10139
  case 4:
9706
10140
  let pos4 = access.pos;
9707
- let beat = access.beat;
9708
- throw haxe_Exception.thrown(new loreline_RuntimeError("Cannot overwrite beat: " + beat.name,pos4));
10141
+ let ref = access.ref;
10142
+ throw haxe_Exception.thrown(new loreline_RuntimeError("Cannot overwrite beat: " + ref.beat.name,pos4));
9709
10143
  }
9710
10144
  }
9711
10145
  resolveAssignmentTarget(target) {
@@ -9742,42 +10176,47 @@ class loreline_Interpreter {
9742
10176
  }
9743
10177
  return loreline_RuntimeAccess.FieldAccess(target.pos,evaluated,name);
9744
10178
  }
9745
- let i = this.stack.length - 1;
9746
- while(i >= 0) {
9747
- let scope = this.stack[i];
10179
+ let scopeAccess = null;
10180
+ let _gthis = this;
10181
+ this.eachResolutionScope(-1,function(scope) {
9748
10182
  if(scope.state != null) {
9749
- if(loreline_Objects.fieldExists(this,scope.state.fields,name)) {
10183
+ if(loreline_Objects.fieldExists(_gthis,scope.state.fields,name)) {
9750
10184
  let tmp = access != null ? access.pos : null;
9751
10185
  let tmp1;
9752
10186
  if(tmp != null) {
9753
10187
  tmp1 = tmp;
9754
10188
  } else {
9755
- let tmp = this.get_currentScope();
10189
+ let tmp = _gthis.get_currentScope();
9756
10190
  let tmp2 = tmp != null ? tmp.node : null;
9757
10191
  tmp1 = tmp2 != null ? tmp2.pos : null;
9758
10192
  }
9759
- return loreline_RuntimeAccess.FieldAccess(tmp1 != null ? tmp1 : this.script.pos,scope.state.fields,name);
10193
+ scopeAccess = loreline_RuntimeAccess.FieldAccess(tmp1 != null ? tmp1 : _gthis.script.pos,scope.state.fields,name);
10194
+ return true;
9760
10195
  }
9761
10196
  }
9762
10197
  if(scope.node != null) {
9763
10198
  let key = scope.node.id.thisVal;
9764
- let stateInNode = this.nodeStates.map._get(key.high,key.low);
10199
+ let stateInNode = _gthis.nodeStates.map._get(key.high,key.low);
9765
10200
  if(stateInNode != null) {
9766
- if(loreline_Objects.fieldExists(this,stateInNode.fields,name)) {
10201
+ if(loreline_Objects.fieldExists(_gthis,stateInNode.fields,name)) {
9767
10202
  let tmp = access != null ? access.pos : null;
9768
10203
  let tmp1;
9769
10204
  if(tmp != null) {
9770
10205
  tmp1 = tmp;
9771
10206
  } else {
9772
- let tmp = this.get_currentScope();
10207
+ let tmp = _gthis.get_currentScope();
9773
10208
  let tmp2 = tmp != null ? tmp.node : null;
9774
10209
  tmp1 = tmp2 != null ? tmp2.pos : null;
9775
10210
  }
9776
- return loreline_RuntimeAccess.FieldAccess(tmp1 != null ? tmp1 : this.script.pos,stateInNode.fields,name);
10211
+ scopeAccess = loreline_RuntimeAccess.FieldAccess(tmp1 != null ? tmp1 : _gthis.script.pos,stateInNode.fields,name);
10212
+ return true;
9777
10213
  }
9778
10214
  }
9779
10215
  }
9780
- --i;
10216
+ return false;
10217
+ });
10218
+ if(scopeAccess != null) {
10219
+ return scopeAccess;
9781
10220
  }
9782
10221
  if(loreline_Objects.fieldExists(this,this.topLevelState.fields,name)) {
9783
10222
  let tmp = access != null ? access.pos : null;
@@ -9815,8 +10254,8 @@ class loreline_Interpreter {
9815
10254
  }
9816
10255
  return loreline_RuntimeAccess.FunctionAccess(tmp1 != null ? tmp1 : this.script.pos,name);
9817
10256
  }
9818
- let beat = this.resolveBeatByName(name);
9819
- if(beat != null) {
10257
+ let beatRef = this.resolveBeatRefFromNode(name,access);
10258
+ if(beatRef != null) {
9820
10259
  let tmp = access != null ? access.pos : null;
9821
10260
  let tmp1;
9822
10261
  if(tmp != null) {
@@ -9826,7 +10265,7 @@ class loreline_Interpreter {
9826
10265
  let tmp2 = tmp != null ? tmp.node : null;
9827
10266
  tmp1 = tmp2 != null ? tmp2.pos : null;
9828
10267
  }
9829
- return loreline_RuntimeAccess.BeatAccess(tmp1 != null ? tmp1 : this.script.pos,beat);
10268
+ return loreline_RuntimeAccess.BeatAccess(tmp1 != null ? tmp1 : this.script.pos,beatRef);
9830
10269
  }
9831
10270
  if(!this.strictAccess) {
9832
10271
  let tmp = access != null ? access.pos : null;
@@ -9840,16 +10279,17 @@ class loreline_Interpreter {
9840
10279
  }
9841
10280
  return loreline_RuntimeAccess.FieldAccess(tmp1 != null ? tmp1 : this.script.pos,this.topLevelState.fields,name);
9842
10281
  }
9843
- let tmp = access != null ? access.pos : null;
9844
- let tmp1;
9845
- if(tmp != null) {
9846
- tmp1 = tmp;
10282
+ let tmp = "Undefined variable: " + name;
10283
+ let tmp1 = access != null ? access.pos : null;
10284
+ let tmp2;
10285
+ if(tmp1 != null) {
10286
+ tmp2 = tmp1;
9847
10287
  } else {
9848
10288
  let tmp = this.get_currentScope();
9849
- let tmp2 = tmp != null ? tmp.node : null;
9850
- tmp1 = tmp2 != null ? tmp2.pos : null;
10289
+ let tmp1 = tmp != null ? tmp.node : null;
10290
+ tmp2 = tmp1 != null ? tmp1.pos : null;
9851
10291
  }
9852
- throw haxe_Exception.thrown(new loreline_RuntimeError("Undefined variable: " + name,tmp1 != null ? tmp1 : this.script.pos));
10292
+ throw haxe_Exception.thrown(new loreline_RuntimeError(tmp,tmp2 != null ? tmp2 : this.script.pos));
9853
10293
  }
9854
10294
  getTypeName(t) {
9855
10295
  switch(t._hx_index) {
@@ -10123,7 +10563,9 @@ class loreline_Interpreter {
10123
10563
  }
10124
10564
  break;
10125
10565
  case 31:case 32:
10126
- let result = ((left) instanceof loreline_NBeatDecl) && typeof(right) == "string" ? left.name == right : typeof(left) == "string" && ((right) instanceof loreline_NBeatDecl) ? left == right.name : ((left) instanceof loreline_NBeatDecl) && ((right) instanceof loreline_NBeatDecl) ? left.name == right.name : left == right;
10566
+ let leftBeat = loreline_RuntimeBeatRef.beatOf(left);
10567
+ let rightBeat = loreline_RuntimeBeatRef.beatOf(right);
10568
+ let result = leftBeat != null && typeof(right) == "string" ? leftBeat.name == right : typeof(left) == "string" && rightBeat != null ? left == rightBeat.name : leftBeat != null && rightBeat != null ? leftBeat.name == rightBeat.name : left == right;
10127
10569
  switch(op._hx_index) {
10128
10570
  case 31:
10129
10571
  return result;
@@ -10343,9 +10785,10 @@ class loreline_Interpreter {
10343
10785
  seen.pop();
10344
10786
  return buf_b;
10345
10787
  }
10346
- if(((value) instanceof loreline_NBeatDecl)) {
10788
+ let asBeat = loreline_RuntimeBeatRef.beatOf(value);
10789
+ if(asBeat != null) {
10347
10790
  seen.pop();
10348
- return value.name;
10791
+ return asBeat.name;
10349
10792
  }
10350
10793
  if(loreline_Objects.isFields(value)) {
10351
10794
  let keys = loreline_Objects.getFields(this,value);
@@ -10455,6 +10898,8 @@ class loreline_JsonToAst {
10455
10898
  return loreline_JsonToAst.assignFromJson(json);
10456
10899
  case "Beat":
10457
10900
  return loreline_JsonToAst.beatFromJson(json);
10901
+ case "BeatCall":
10902
+ return loreline_JsonToAst.beatCallFromJson(json);
10458
10903
  case "Binary":
10459
10904
  return loreline_JsonToAst.binaryFromJson(json);
10460
10905
  case "Block":
@@ -10565,6 +11010,17 @@ class loreline_JsonToAst {
10565
11010
  let comments = loreline_JsonToAst.extractComments(json);
10566
11011
  let node = new loreline_NBeatDecl(id,pos,json.name,body,comments.leading,comments.trailing);
10567
11012
  node.style = loreline_JsonToAst.blockStyleFromString(json.style);
11013
+ if(json.params != null) {
11014
+ let paramsArr = json.params;
11015
+ let _g = [];
11016
+ let _g1 = 0;
11017
+ while(_g1 < paramsArr.length) {
11018
+ let p = paramsArr[_g1];
11019
+ ++_g1;
11020
+ _g.push(new loreline_NBeatParam(p.name,loreline_JsonToAst.positionFromJson(p.namePos),p.defaultValue != null ? loreline_JsonToAst.nodeFromJson(p.defaultValue) : null));
11021
+ }
11022
+ node.params = _g;
11023
+ }
10568
11024
  return node;
10569
11025
  }
10570
11026
  static stringPartFromJson(json) {
@@ -10813,14 +11269,64 @@ class loreline_JsonToAst {
10813
11269
  let pos = loreline_JsonToAst.positionFromJson(json.pos);
10814
11270
  let targetPos = loreline_JsonToAst.positionFromJson(json.targetPos);
10815
11271
  let comments = loreline_JsonToAst.extractComments(json);
10816
- return new loreline_NTransition(id,pos,json.target,targetPos,comments.leading,comments.trailing);
11272
+ let node = new loreline_NTransition(id,pos,json.target,targetPos,comments.leading,comments.trailing);
11273
+ if(json.targetExpr != null) {
11274
+ node.targetExpr = loreline_JsonToAst.nodeFromJson(json.targetExpr);
11275
+ }
11276
+ if(json.args != null) {
11277
+ let argsArr = json.args;
11278
+ let _g = [];
11279
+ let _g1 = 0;
11280
+ while(_g1 < argsArr.length) {
11281
+ let a = argsArr[_g1];
11282
+ ++_g1;
11283
+ _g.push(loreline_JsonToAst.nodeFromJson(a));
11284
+ }
11285
+ node.args = _g;
11286
+ }
11287
+ return node;
11288
+ }
11289
+ static beatCallFromJson(json) {
11290
+ let id = loreline_JsonToAst.idFromJson(json);
11291
+ let pos = loreline_JsonToAst.positionFromJson(json.pos);
11292
+ let targetPos = loreline_JsonToAst.positionFromJson(json.targetPos);
11293
+ let targetExpr = loreline_JsonToAst.nodeFromJson(json.targetExpr);
11294
+ let comments = loreline_JsonToAst.extractComments(json);
11295
+ let node = new loreline_NBeatCall(id,pos,targetExpr,targetPos,comments.leading,comments.trailing);
11296
+ if(json.args != null) {
11297
+ let argsArr = json.args;
11298
+ let _g = [];
11299
+ let _g1 = 0;
11300
+ while(_g1 < argsArr.length) {
11301
+ let a = argsArr[_g1];
11302
+ ++_g1;
11303
+ _g.push(loreline_JsonToAst.nodeFromJson(a));
11304
+ }
11305
+ node.args = _g;
11306
+ }
11307
+ return node;
10817
11308
  }
10818
11309
  static insertionFromJson(json) {
10819
11310
  let id = loreline_JsonToAst.idFromJson(json);
10820
11311
  let pos = loreline_JsonToAst.positionFromJson(json.pos);
10821
11312
  let targetPos = loreline_JsonToAst.positionFromJson(json.targetPos);
10822
11313
  let comments = loreline_JsonToAst.extractComments(json);
10823
- return new loreline_NInsertion(id,pos,json.target,targetPos,comments.leading,comments.trailing);
11314
+ let node = new loreline_NInsertion(id,pos,json.target,targetPos,comments.leading,comments.trailing);
11315
+ if(json.targetExpr != null) {
11316
+ node.targetExpr = loreline_JsonToAst.nodeFromJson(json.targetExpr);
11317
+ }
11318
+ if(json.args != null) {
11319
+ let argsArr = json.args;
11320
+ let _g = [];
11321
+ let _g1 = 0;
11322
+ while(_g1 < argsArr.length) {
11323
+ let a = argsArr[_g1];
11324
+ ++_g1;
11325
+ _g.push(loreline_JsonToAst.nodeFromJson(a));
11326
+ }
11327
+ node.args = _g;
11328
+ }
11329
+ return node;
10824
11330
  }
10825
11331
  static functionDeclFromJson(json) {
10826
11332
  let id = loreline_JsonToAst.idFromJson(json);
@@ -11118,7 +11624,7 @@ class loreline_FuncLorscript {
11118
11624
  let e = haxe_Exception.caught(_g).unwrap();
11119
11625
  if(((e) instanceof loreline_Error)) {
11120
11626
  this.error = e;
11121
- this.error.pos = func.pos.withOffset(this.codeToLorscript.input,this.error.pos.offset,this.error.pos.length,func.pos.offset);
11627
+ this.error.pos = func.pos.withOffset(this.codeToLorscript.inputText,this.error.pos.offset,this.error.pos.length,func.pos.offset);
11122
11628
  }
11123
11629
  this.lorscript = this.codeToLorscript.output.b;
11124
11630
  }
@@ -11179,7 +11685,7 @@ class loreline_FuncLorscript {
11179
11685
  this.error = new loreline_WrappedError(lorscriptError,tmp,this.codeToLorscript.toLorelinePos(func.pos,lorscriptError.pmin,lorscriptError.pmax));
11180
11686
  } else if(((e) instanceof loreline_Error)) {
11181
11687
  this.error = e;
11182
- this.error.pos = func.pos.withOffset(this.codeToLorscript.input,this.error.pos.offset,this.error.pos.length,func.pos.offset);
11688
+ this.error.pos = func.pos.withOffset(this.codeToLorscript.inputText,this.error.pos.offset,this.error.pos.length,func.pos.offset);
11183
11689
  }
11184
11690
  }
11185
11691
  try {
@@ -12227,10 +12733,88 @@ class loreline_Lens {
12227
12733
  }
12228
12734
  return null;
12229
12735
  }
12736
+ findBeatParamFromAccess(access) {
12737
+ if(access.target != null || access.name == null) {
12738
+ return null;
12739
+ }
12740
+ let parentBeat = this.getFirstParentOfType(access,loreline_NBeatDecl);
12741
+ while(parentBeat != null) {
12742
+ if(parentBeat.params != null) {
12743
+ let _g = 0;
12744
+ let _g1 = parentBeat.params;
12745
+ while(_g < _g1.length) {
12746
+ let param = _g1[_g];
12747
+ ++_g;
12748
+ if(param.name == access.name) {
12749
+ return { param : param, beat : parentBeat};
12750
+ }
12751
+ }
12752
+ }
12753
+ parentBeat = this.getFirstParentOfType(parentBeat,loreline_NBeatDecl);
12754
+ }
12755
+ return null;
12756
+ }
12757
+ findCallArgument(node) {
12758
+ let child = node;
12759
+ let parent = this.getParentNode(child);
12760
+ while(parent != null) {
12761
+ switch(js_Boot.getClass(parent)) {
12762
+ case loreline_NBeatCall:
12763
+ let beatCall = parent;
12764
+ if(beatCall.args != null) {
12765
+ let index = beatCall.args.indexOf(child);
12766
+ if(index != -1) {
12767
+ return { owner : parent, index : index};
12768
+ }
12769
+ }
12770
+ return null;
12771
+ case loreline_NCall:
12772
+ let call = parent;
12773
+ if(call.args != null) {
12774
+ let index = call.args.indexOf(child);
12775
+ if(index != -1) {
12776
+ return { owner : parent, index : index};
12777
+ }
12778
+ }
12779
+ return null;
12780
+ case loreline_NInsertion:
12781
+ let insertion = parent;
12782
+ if(insertion.args != null) {
12783
+ let index = insertion.args.indexOf(child);
12784
+ if(index != -1) {
12785
+ return { owner : parent, index : index};
12786
+ }
12787
+ }
12788
+ return null;
12789
+ case loreline_NTransition:
12790
+ let transition = parent;
12791
+ if(transition.args != null) {
12792
+ let index = transition.args.indexOf(child);
12793
+ if(index != -1) {
12794
+ return { owner : parent, index : index};
12795
+ }
12796
+ }
12797
+ return null;
12798
+ default:
12799
+ if(!((parent) instanceof loreline_NExpr)) {
12800
+ return null;
12801
+ }
12802
+ }
12803
+ child = parent;
12804
+ parent = this.getParentNode(child);
12805
+ }
12806
+ return null;
12807
+ }
12230
12808
  findBeatFromTransition(transition) {
12809
+ if(transition.targetExpr != null) {
12810
+ return null;
12811
+ }
12231
12812
  return this.findBeatByNameFromNode(transition.target,transition);
12232
12813
  }
12233
12814
  findBeatFromInsertion(insertion) {
12815
+ if(insertion.targetExpr != null) {
12816
+ return null;
12817
+ }
12234
12818
  return this.findBeatByNameFromNode(insertion.target,insertion);
12235
12819
  }
12236
12820
  findBeatByPathFromNode(path,node) {
@@ -12539,22 +13123,26 @@ class loreline_Lens {
12539
13123
  break;
12540
13124
  case loreline_NInsertion:
12541
13125
  let insertion = node;
12542
- let targetBeat = _gthis.findBeatByNameFromNode(insertion.target,insertion);
12543
- if(targetBeat != null) {
12544
- let key = targetBeat.id;
12545
- let value = new loreline_Reference(targetBeat,insertion);
12546
- let key1 = key.thisVal;
12547
- targetBeats_map._set(key1.high,key1.low,value);
13126
+ if(insertion.targetExpr == null) {
13127
+ let targetBeat = _gthis.findBeatByNameFromNode(insertion.target,insertion);
13128
+ if(targetBeat != null) {
13129
+ let key = targetBeat.id;
13130
+ let value = new loreline_Reference(targetBeat,insertion);
13131
+ let key1 = key.thisVal;
13132
+ targetBeats_map._set(key1.high,key1.low,value);
13133
+ }
12548
13134
  }
12549
13135
  break;
12550
13136
  case loreline_NTransition:
12551
13137
  let transition = node;
12552
- let targetBeat1 = _gthis.findBeatByNameFromNode(transition.target,transition);
12553
- if(targetBeat1 != null) {
12554
- let key = targetBeat1.id;
12555
- let value = new loreline_Reference(targetBeat1,transition);
12556
- let key1 = key.thisVal;
12557
- targetBeats_map._set(key1.high,key1.low,value);
13138
+ if(transition.targetExpr == null) {
13139
+ let targetBeat = _gthis.findBeatByNameFromNode(transition.target,transition);
13140
+ if(targetBeat != null) {
13141
+ let key = targetBeat.id;
13142
+ let value = new loreline_Reference(targetBeat,transition);
13143
+ let key1 = key.thisVal;
13144
+ targetBeats_map._set(key1.high,key1.low,value);
13145
+ }
12558
13146
  }
12559
13147
  break;
12560
13148
  default:
@@ -13791,7 +14379,54 @@ class loreline_Lexer {
13791
14379
  this.nextBlock = 3;
13792
14380
  break;
13793
14381
  case 2:
13794
- this.nextBlock = 7;
14382
+ let prevIndex = tokens.length - 2;
14383
+ _hx_loop3: while(prevIndex >= 0) {
14384
+ let _g = tokens[prevIndex].type;
14385
+ switch(_g._hx_index) {
14386
+ case 51:
14387
+ let _g1 = _g.content;
14388
+ --prevIndex;
14389
+ break;
14390
+ case 52:
14391
+ let _g2 = _g.content;
14392
+ --prevIndex;
14393
+ break;
14394
+ default:
14395
+ break _hx_loop3;
14396
+ }
14397
+ }
14398
+ let isDynamicTargetKeyword;
14399
+ if(prevIndex >= 0) {
14400
+ switch(tokens[prevIndex].type._hx_index) {
14401
+ case 26:case 40:
14402
+ isDynamicTargetKeyword = true;
14403
+ break;
14404
+ default:
14405
+ isDynamicTargetKeyword = false;
14406
+ }
14407
+ } else {
14408
+ isDynamicTargetKeyword = false;
14409
+ }
14410
+ let lookahead = this.pos;
14411
+ while(lookahead < this.length) {
14412
+ let c = HxOverrides.cca(this.input,lookahead);
14413
+ let c1 = c == null ? -1 : c;
14414
+ if(c1 == 32 || c1 == 9) {
14415
+ ++lookahead;
14416
+ } else {
14417
+ break;
14418
+ }
14419
+ }
14420
+ let isBeatCallStatement;
14421
+ if(lookahead < this.length) {
14422
+ let c = HxOverrides.cca(this.input,lookahead);
14423
+ isBeatCallStatement = (c == null ? -1 : c) == 40;
14424
+ } else {
14425
+ isBeatCallStatement = false;
14426
+ }
14427
+ if(!isDynamicTargetKeyword && !isBeatCallStatement) {
14428
+ this.nextBlock = 7;
14429
+ }
13795
14430
  break;
13796
14431
  case 3:
13797
14432
  this.nextBlock = 5;
@@ -15523,7 +16158,13 @@ class loreline_Lexer {
15523
16158
  if(pos == startPos && startPos < this.length) {
15524
16159
  let c = HxOverrides.cca(this.input,startPos);
15525
16160
  let c1 = c == null ? -1 : c;
15526
- tmp1 = c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95;
16161
+ if(!(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95)) {
16162
+ let c = HxOverrides.cca(this.input,startPos);
16163
+ let c1 = c == null ? -1 : c;
16164
+ tmp1 = c1 >= 48 && c1 <= 57;
16165
+ } else {
16166
+ tmp1 = true;
16167
+ }
15527
16168
  } else {
15528
16169
  tmp1 = false;
15529
16170
  }
@@ -15534,7 +16175,13 @@ class loreline_Lexer {
15534
16175
  if(pos < this.length) {
15535
16176
  let c = HxOverrides.cca(this.input,pos);
15536
16177
  let c1 = c == null ? -1 : c;
15537
- tmp2 = !(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95);
16178
+ if(!(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95)) {
16179
+ let c = HxOverrides.cca(this.input,pos);
16180
+ let c1 = c == null ? -1 : c;
16181
+ tmp2 = !(c1 >= 48 && c1 <= 57);
16182
+ } else {
16183
+ tmp2 = false;
16184
+ }
15538
16185
  } else {
15539
16186
  tmp2 = true;
15540
16187
  }
@@ -15547,65 +16194,52 @@ class loreline_Lexer {
15547
16194
  if((c == null ? -1 : c) == 40) {
15548
16195
  return true;
15549
16196
  } else {
15550
- let result = true;
15551
- let len = _gthis.length;
15552
- if(pos >= len) {
15553
- result = false;
15554
- } else {
15555
- let tmp;
15556
- let tmp1;
15557
- let tmp2;
15558
- if(pos + 1 < len) {
15559
- let c = HxOverrides.cca(_gthis.input,pos);
15560
- tmp2 = (c == null ? -1 : c) == 111;
15561
- } else {
15562
- tmp2 = false;
15563
- }
15564
- if(tmp2) {
15565
- let c = HxOverrides.cca(_gthis.input,pos + 1);
15566
- tmp1 = (c == null ? -1 : c) == 114;
15567
- } else {
15568
- tmp1 = false;
15569
- }
15570
- if(tmp1) {
15571
- if(pos + 2 < len) {
15572
- let c = HxOverrides.cca(_gthis.input,pos + 2);
16197
+ let c = HxOverrides.cca(this.input,pos);
16198
+ let c1 = c == null ? -1 : c;
16199
+ if(c1 >= 48 && c1 <= 57) {
16200
+ while(true) {
16201
+ let tmp;
16202
+ if(pos < this.length) {
16203
+ let c = HxOverrides.cca(this.input,pos);
15573
16204
  let c1 = c == null ? -1 : c;
15574
- tmp = !(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95);
16205
+ if(!(c1 >= 48 && c1 <= 57)) {
16206
+ let c = HxOverrides.cca(this.input,pos);
16207
+ tmp = (c == null ? -1 : c) == 46;
16208
+ } else {
16209
+ tmp = true;
16210
+ }
15575
16211
  } else {
15576
- tmp = true;
16212
+ tmp = false;
15577
16213
  }
15578
- } else {
15579
- tmp = false;
16214
+ if(!tmp) {
16215
+ break;
16216
+ }
16217
+ ++pos;
15580
16218
  }
15581
- if(tmp) {
16219
+ } else {
16220
+ let result = true;
16221
+ let len = _gthis.length;
16222
+ if(pos >= len) {
15582
16223
  result = false;
15583
16224
  } else {
15584
16225
  let tmp;
15585
16226
  let tmp1;
15586
16227
  let tmp2;
15587
- let tmp3;
15588
- if(pos + 2 < len) {
16228
+ if(pos + 1 < len) {
15589
16229
  let c = HxOverrides.cca(_gthis.input,pos);
15590
- tmp3 = (c == null ? -1 : c) == 97;
15591
- } else {
15592
- tmp3 = false;
15593
- }
15594
- if(tmp3) {
15595
- let c = HxOverrides.cca(_gthis.input,pos + 1);
15596
- tmp2 = (c == null ? -1 : c) == 110;
16230
+ tmp2 = (c == null ? -1 : c) == 111;
15597
16231
  } else {
15598
16232
  tmp2 = false;
15599
16233
  }
15600
16234
  if(tmp2) {
15601
- let c = HxOverrides.cca(_gthis.input,pos + 2);
15602
- tmp1 = (c == null ? -1 : c) == 100;
16235
+ let c = HxOverrides.cca(_gthis.input,pos + 1);
16236
+ tmp1 = (c == null ? -1 : c) == 114;
15603
16237
  } else {
15604
16238
  tmp1 = false;
15605
16239
  }
15606
16240
  if(tmp1) {
15607
- if(pos + 3 < len) {
15608
- let c = HxOverrides.cca(_gthis.input,pos + 3);
16241
+ if(pos + 2 < len) {
16242
+ let c = HxOverrides.cca(_gthis.input,pos + 2);
15609
16243
  let c1 = c == null ? -1 : c;
15610
16244
  tmp = !(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95);
15611
16245
  } else {
@@ -15617,26 +16251,63 @@ class loreline_Lexer {
15617
16251
  if(tmp) {
15618
16252
  result = false;
15619
16253
  } else {
15620
- let c = HxOverrides.cca(_gthis.input,pos);
15621
- let c1 = c == null ? -1 : c;
15622
- if(!(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95)) {
16254
+ let tmp;
16255
+ let tmp1;
16256
+ let tmp2;
16257
+ let tmp3;
16258
+ if(pos + 2 < len) {
16259
+ let c = HxOverrides.cca(_gthis.input,pos);
16260
+ tmp3 = (c == null ? -1 : c) == 97;
16261
+ } else {
16262
+ tmp3 = false;
16263
+ }
16264
+ if(tmp3) {
16265
+ let c = HxOverrides.cca(_gthis.input,pos + 1);
16266
+ tmp2 = (c == null ? -1 : c) == 110;
16267
+ } else {
16268
+ tmp2 = false;
16269
+ }
16270
+ if(tmp2) {
16271
+ let c = HxOverrides.cca(_gthis.input,pos + 2);
16272
+ tmp1 = (c == null ? -1 : c) == 100;
16273
+ } else {
16274
+ tmp1 = false;
16275
+ }
16276
+ if(tmp1) {
16277
+ if(pos + 3 < len) {
16278
+ let c = HxOverrides.cca(_gthis.input,pos + 3);
16279
+ let c1 = c == null ? -1 : c;
16280
+ tmp = !(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95);
16281
+ } else {
16282
+ tmp = true;
16283
+ }
16284
+ } else {
16285
+ tmp = false;
16286
+ }
16287
+ if(tmp) {
15623
16288
  result = false;
15624
16289
  } else {
15625
- ++pos;
15626
- while(pos < _gthis.length) {
15627
- let c = HxOverrides.cca(_gthis.input,pos);
15628
- c1 = c == null ? -1 : c;
15629
- if(!(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95 || c1 >= 48 && c1 <= 57)) {
15630
- break;
15631
- }
16290
+ let c = HxOverrides.cca(_gthis.input,pos);
16291
+ let c1 = c == null ? -1 : c;
16292
+ if(!(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95)) {
16293
+ result = false;
16294
+ } else {
15632
16295
  ++pos;
16296
+ while(pos < _gthis.length) {
16297
+ let c = HxOverrides.cca(_gthis.input,pos);
16298
+ c1 = c == null ? -1 : c;
16299
+ if(!(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95 || c1 >= 48 && c1 <= 57)) {
16300
+ break;
16301
+ }
16302
+ ++pos;
16303
+ }
15633
16304
  }
15634
16305
  }
15635
16306
  }
15636
16307
  }
15637
- }
15638
- if(!result) {
15639
- return false;
16308
+ if(!result) {
16309
+ return false;
16310
+ }
15640
16311
  }
15641
16312
  }
15642
16313
  pos = this._skipWhitespaceAndComments(pos,false);
@@ -15645,68 +16316,33 @@ class loreline_Lexer {
15645
16316
  }
15646
16317
  let c1 = HxOverrides.cca(this.input,pos);
15647
16318
  let c2 = c1 == null ? -1 : c1;
15648
- if(c2 == 46) {
15649
- ++pos;
15650
- pos = this._skipWhitespaceAndComments(pos,false);
15651
- let result = true;
15652
- let len = _gthis.length;
15653
- if(pos >= len) {
15654
- result = false;
15655
- } else {
15656
- let tmp;
15657
- let tmp1;
15658
- let tmp2;
15659
- if(pos + 1 < len) {
15660
- let c = HxOverrides.cca(_gthis.input,pos);
15661
- tmp2 = (c == null ? -1 : c) == 111;
15662
- } else {
15663
- tmp2 = false;
15664
- }
15665
- if(tmp2) {
15666
- let c = HxOverrides.cca(_gthis.input,pos + 1);
15667
- tmp1 = (c == null ? -1 : c) == 114;
15668
- } else {
15669
- tmp1 = false;
15670
- }
15671
- if(tmp1) {
15672
- if(pos + 2 < len) {
15673
- let c = HxOverrides.cca(_gthis.input,pos + 2);
15674
- let c1 = c == null ? -1 : c;
15675
- tmp = !(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95);
15676
- } else {
15677
- tmp = true;
15678
- }
15679
- } else {
15680
- tmp = false;
15681
- }
15682
- if(tmp) {
16319
+ while(c2 == 46 || c2 == 91) {
16320
+ if(c2 == 46) {
16321
+ ++pos;
16322
+ pos = this._skipWhitespaceAndComments(pos,false);
16323
+ let result = true;
16324
+ let len = _gthis.length;
16325
+ if(pos >= len) {
15683
16326
  result = false;
15684
16327
  } else {
15685
16328
  let tmp;
15686
16329
  let tmp1;
15687
16330
  let tmp2;
15688
- let tmp3;
15689
- if(pos + 2 < len) {
16331
+ if(pos + 1 < len) {
15690
16332
  let c = HxOverrides.cca(_gthis.input,pos);
15691
- tmp3 = (c == null ? -1 : c) == 97;
15692
- } else {
15693
- tmp3 = false;
15694
- }
15695
- if(tmp3) {
15696
- let c = HxOverrides.cca(_gthis.input,pos + 1);
15697
- tmp2 = (c == null ? -1 : c) == 110;
16333
+ tmp2 = (c == null ? -1 : c) == 111;
15698
16334
  } else {
15699
16335
  tmp2 = false;
15700
16336
  }
15701
16337
  if(tmp2) {
15702
- let c = HxOverrides.cca(_gthis.input,pos + 2);
15703
- tmp1 = (c == null ? -1 : c) == 100;
16338
+ let c = HxOverrides.cca(_gthis.input,pos + 1);
16339
+ tmp1 = (c == null ? -1 : c) == 114;
15704
16340
  } else {
15705
16341
  tmp1 = false;
15706
16342
  }
15707
16343
  if(tmp1) {
15708
- if(pos + 3 < len) {
15709
- let c = HxOverrides.cca(_gthis.input,pos + 3);
16344
+ if(pos + 2 < len) {
16345
+ let c = HxOverrides.cca(_gthis.input,pos + 2);
15710
16346
  let c1 = c == null ? -1 : c;
15711
16347
  tmp = !(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95);
15712
16348
  } else {
@@ -15718,47 +16354,77 @@ class loreline_Lexer {
15718
16354
  if(tmp) {
15719
16355
  result = false;
15720
16356
  } else {
15721
- let c = HxOverrides.cca(_gthis.input,pos);
15722
- let c1 = c == null ? -1 : c;
15723
- if(!(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95)) {
16357
+ let tmp;
16358
+ let tmp1;
16359
+ let tmp2;
16360
+ let tmp3;
16361
+ if(pos + 2 < len) {
16362
+ let c = HxOverrides.cca(_gthis.input,pos);
16363
+ tmp3 = (c == null ? -1 : c) == 97;
16364
+ } else {
16365
+ tmp3 = false;
16366
+ }
16367
+ if(tmp3) {
16368
+ let c = HxOverrides.cca(_gthis.input,pos + 1);
16369
+ tmp2 = (c == null ? -1 : c) == 110;
16370
+ } else {
16371
+ tmp2 = false;
16372
+ }
16373
+ if(tmp2) {
16374
+ let c = HxOverrides.cca(_gthis.input,pos + 2);
16375
+ tmp1 = (c == null ? -1 : c) == 100;
16376
+ } else {
16377
+ tmp1 = false;
16378
+ }
16379
+ if(tmp1) {
16380
+ if(pos + 3 < len) {
16381
+ let c = HxOverrides.cca(_gthis.input,pos + 3);
16382
+ let c1 = c == null ? -1 : c;
16383
+ tmp = !(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95);
16384
+ } else {
16385
+ tmp = true;
16386
+ }
16387
+ } else {
16388
+ tmp = false;
16389
+ }
16390
+ if(tmp) {
15724
16391
  result = false;
15725
16392
  } else {
15726
- ++pos;
15727
- while(pos < _gthis.length) {
15728
- let c = HxOverrides.cca(_gthis.input,pos);
15729
- c1 = c == null ? -1 : c;
15730
- if(!(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95 || c1 >= 48 && c1 <= 57)) {
15731
- break;
15732
- }
16393
+ let c = HxOverrides.cca(_gthis.input,pos);
16394
+ let c1 = c == null ? -1 : c;
16395
+ if(!(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95)) {
16396
+ result = false;
16397
+ } else {
15733
16398
  ++pos;
16399
+ while(pos < _gthis.length) {
16400
+ let c = HxOverrides.cca(_gthis.input,pos);
16401
+ c1 = c == null ? -1 : c;
16402
+ if(!(c1 >= 97 && c1 <= 122 || c1 >= 65 && c1 <= 90 || c1 == 95 || c1 >= 48 && c1 <= 57)) {
16403
+ break;
16404
+ }
16405
+ ++pos;
16406
+ }
15734
16407
  }
15735
16408
  }
15736
16409
  }
15737
16410
  }
15738
- }
15739
- if(!result) {
15740
- return true;
15741
- }
15742
- pos = this._skipWhitespaceAndComments(pos,false);
15743
- if(pos >= this.length) {
15744
- return true;
15745
- }
15746
- let c = HxOverrides.cca(this.input,pos);
15747
- c2 = c == null ? -1 : c;
15748
- }
15749
- if(c2 == 91) {
15750
- ++pos;
15751
- let bracketLevel = 1;
15752
- while(pos < this.length && bracketLevel > 0) {
15753
- let c = HxOverrides.cca(this.input,pos);
15754
- c2 = c == null ? -1 : c;
15755
- if(c2 == 91) {
15756
- ++bracketLevel;
15757
- }
15758
- if(c2 == 93) {
15759
- --bracketLevel;
16411
+ if(!result) {
16412
+ return true;
15760
16413
  }
16414
+ } else {
15761
16415
  ++pos;
16416
+ let bracketLevel = 1;
16417
+ while(pos < this.length && bracketLevel > 0) {
16418
+ let c = HxOverrides.cca(this.input,pos);
16419
+ c2 = c == null ? -1 : c;
16420
+ if(c2 == 91) {
16421
+ ++bracketLevel;
16422
+ }
16423
+ if(c2 == 93) {
16424
+ --bracketLevel;
16425
+ }
16426
+ ++pos;
16427
+ }
15762
16428
  }
15763
16429
  pos = this._skipWhitespaceAndComments(pos,false);
15764
16430
  if(pos >= this.length) {
@@ -16069,6 +16735,19 @@ class loreline_Lexer {
16069
16735
  }
16070
16736
  ++pos;
16071
16737
  }
16738
+ let tmp;
16739
+ if(pos < this.length) {
16740
+ let c = HxOverrides.cca(this.input,pos);
16741
+ tmp = (c == null ? -1 : c) == 40;
16742
+ } else {
16743
+ tmp = false;
16744
+ }
16745
+ if(tmp) {
16746
+ pos = this.skipBalancedParens(pos,this.parentBlockType() == loreline_TokenType.KwBeat);
16747
+ if(pos == -1) {
16748
+ return false;
16749
+ }
16750
+ }
16072
16751
  } else {
16073
16752
  return false;
16074
16753
  }
@@ -16116,6 +16795,19 @@ class loreline_Lexer {
16116
16795
  }
16117
16796
  ++pos;
16118
16797
  }
16798
+ let tmp;
16799
+ if(pos < this.length) {
16800
+ let c = HxOverrides.cca(this.input,pos);
16801
+ tmp = (c == null ? -1 : c) == 40;
16802
+ } else {
16803
+ tmp = false;
16804
+ }
16805
+ if(tmp) {
16806
+ pos = this.skipBalancedParens(pos,this.parentBlockType() == loreline_TokenType.KwBeat);
16807
+ if(pos == -1) {
16808
+ return false;
16809
+ }
16810
+ }
16119
16811
  } else {
16120
16812
  return false;
16121
16813
  }
@@ -16919,7 +17611,13 @@ class loreline_Lexer {
16919
17611
  if(loreline_TokenTypeHelpers.isComment(token.type) || token.type == loreline_TokenType.Indent || token.type == loreline_TokenType.Unindent) {
16920
17612
  --i;
16921
17613
  } else if(token.type == loreline_TokenType.OpMinus) {
16922
- return true;
17614
+ --i;
17615
+ while(i >= 0 && (loreline_TokenTypeHelpers.isComment(this.tokenized[i].type) || this.tokenized[i].type == loreline_TokenType.Indent || this.tokenized[i].type == loreline_TokenType.Unindent)) --i;
17616
+ if(i >= 0) {
17617
+ return this.tokenized[i].type == loreline_TokenType.LineBreak;
17618
+ } else {
17619
+ return true;
17620
+ }
16923
17621
  } else {
16924
17622
  return false;
16925
17623
  }
@@ -17064,11 +17762,11 @@ class loreline_Lexer {
17064
17762
  let token = this.tokenized[i];
17065
17763
  let _g = token.type;
17066
17764
  switch(_g._hx_index) {
17765
+ case 2:case 48:case 50:
17766
+ return true;
17067
17767
  case 19:
17068
17768
  let _g1 = _g.name;
17069
17769
  return true;
17070
- case 48:case 50:
17071
- return true;
17072
17770
  case 51:
17073
17771
  let _g2 = _g.content;
17074
17772
  break;
@@ -17401,6 +18099,97 @@ class loreline_Lexer {
17401
18099
  }
17402
18100
  return p;
17403
18101
  }
18102
+ skipBalancedParens(p,allowTags) {
18103
+ let tmp;
18104
+ if(p < this.length) {
18105
+ let c = HxOverrides.cca(this.input,p);
18106
+ tmp = (c == null ? -1 : c) != 40;
18107
+ } else {
18108
+ tmp = true;
18109
+ }
18110
+ if(tmp) {
18111
+ return -1;
18112
+ }
18113
+ ++p;
18114
+ let depth = 1;
18115
+ while(p < this.length && depth > 0) {
18116
+ let c = HxOverrides.cca(this.input,p);
18117
+ let ic = c == null ? -1 : c;
18118
+ if(ic == 92) {
18119
+ p += 2;
18120
+ continue;
18121
+ }
18122
+ if(ic == 10) {
18123
+ return -1;
18124
+ }
18125
+ let tmp;
18126
+ if(ic == 47 && p + 1 < this.length) {
18127
+ let c = HxOverrides.cca(this.input,p + 1);
18128
+ tmp = (c == null ? -1 : c) == 47;
18129
+ } else {
18130
+ tmp = false;
18131
+ }
18132
+ if(tmp) {
18133
+ return -1;
18134
+ }
18135
+ let tmp1;
18136
+ if(ic == 47 && p + 1 < this.length) {
18137
+ let c = HxOverrides.cca(this.input,p + 1);
18138
+ tmp1 = (c == null ? -1 : c) == 42;
18139
+ } else {
18140
+ tmp1 = false;
18141
+ }
18142
+ if(tmp1) {
18143
+ p += 2;
18144
+ while(true) {
18145
+ if(p >= this.length) {
18146
+ return -1;
18147
+ }
18148
+ let c = HxOverrides.cca(this.input,p);
18149
+ if((c == null ? -1 : c) == 10) {
18150
+ return -1;
18151
+ }
18152
+ let tmp;
18153
+ let tmp1;
18154
+ if(p + 1 < this.length) {
18155
+ let c = HxOverrides.cca(this.input,p);
18156
+ tmp1 = (c == null ? -1 : c) == 42;
18157
+ } else {
18158
+ tmp1 = false;
18159
+ }
18160
+ if(tmp1) {
18161
+ let c = HxOverrides.cca(this.input,p + 1);
18162
+ tmp = (c == null ? -1 : c) == 47;
18163
+ } else {
18164
+ tmp = false;
18165
+ }
18166
+ if(tmp) {
18167
+ p += 2;
18168
+ break;
18169
+ }
18170
+ ++p;
18171
+ }
18172
+ continue;
18173
+ }
18174
+ if(ic == 34) {
18175
+ p = this.scanStringEnd(p,allowTags);
18176
+ if(p == -1) {
18177
+ return -1;
18178
+ }
18179
+ continue;
18180
+ }
18181
+ if(ic == 40) {
18182
+ ++depth;
18183
+ } else if(ic == 41) {
18184
+ --depth;
18185
+ }
18186
+ ++p;
18187
+ }
18188
+ if(depth != 0) {
18189
+ return -1;
18190
+ }
18191
+ return p;
18192
+ }
17404
18193
  tryReadUnquotedString() {
17405
18194
  if(this.isStrict()) {
17406
18195
  return null;
@@ -21746,9 +22535,35 @@ loreline_NCharacterDecl.__super__ = loreline_AstNode;
21746
22535
  Object.assign(loreline_NCharacterDecl.prototype, {
21747
22536
  __class__: loreline_NCharacterDecl
21748
22537
  });
22538
+ class loreline_NBeatParam {
22539
+ constructor(name,namePos,defaultValue) {
22540
+ this.name = name;
22541
+ this.namePos = namePos;
22542
+ this.defaultValue = defaultValue;
22543
+ }
22544
+ toJson() {
22545
+ let json = { name : this.name, namePos : this.namePos.toJson()};
22546
+ if(this.defaultValue != null) {
22547
+ json.defaultValue = this.defaultValue.toJson();
22548
+ }
22549
+ return json;
22550
+ }
22551
+ }
22552
+ $hxClasses["loreline.NBeatParam"] = loreline_NBeatParam;
22553
+ loreline_NBeatParam.__name__ = "loreline.NBeatParam";
22554
+ Object.assign(loreline_NBeatParam.prototype, {
22555
+ __class__: loreline_NBeatParam
22556
+ });
21749
22557
  class loreline_NBeatDecl extends loreline_AstNode {
21750
22558
  constructor(id,pos,name,body,leadingComments,trailingComments) {
21751
- super(id,pos,leadingComments,trailingComments);
22559
+ loreline_Node._hx_skip_constructor = true;
22560
+ super();
22561
+ loreline_Node._hx_skip_constructor = false;
22562
+ this._hx_constructor(id,pos,name,body,leadingComments,trailingComments);
22563
+ }
22564
+ _hx_constructor(id,pos,name,body,leadingComments,trailingComments) {
22565
+ this.params = null;
22566
+ super._hx_constructor(id,pos,leadingComments,trailingComments);
21752
22567
  this.name = name;
21753
22568
  this.body = body;
21754
22569
  this.style = 0;
@@ -21758,6 +22573,18 @@ class loreline_NBeatDecl extends loreline_AstNode {
21758
22573
  }
21759
22574
  each(handleNode) {
21760
22575
  super.each(handleNode);
22576
+ if(this.params != null) {
22577
+ let _g = 0;
22578
+ let _g1 = this.params;
22579
+ while(_g < _g1.length) {
22580
+ let param = _g1[_g];
22581
+ ++_g;
22582
+ if(param.defaultValue != null) {
22583
+ handleNode(param.defaultValue,this);
22584
+ param.defaultValue.each(handleNode);
22585
+ }
22586
+ }
22587
+ }
21761
22588
  if(this.body != null) {
21762
22589
  let _g = 0;
21763
22590
  let _g1 = this.body.length;
@@ -21772,6 +22599,17 @@ class loreline_NBeatDecl extends loreline_AstNode {
21772
22599
  toJson() {
21773
22600
  let json = super.toJson();
21774
22601
  json.name = this.name;
22602
+ if(this.params != null) {
22603
+ let _g = [];
22604
+ let _g1 = 0;
22605
+ let _g2 = this.params;
22606
+ while(_g1 < _g2.length) {
22607
+ let param = _g2[_g1];
22608
+ ++_g1;
22609
+ _g.push(param.toJson());
22610
+ }
22611
+ json.params = _g;
22612
+ }
21775
22613
  let _g = [];
21776
22614
  let _g1 = 0;
21777
22615
  let _g2 = this.body;
@@ -22419,17 +23257,57 @@ Object.assign(loreline_NCall.prototype, {
22419
23257
  });
22420
23258
  class loreline_NTransition extends loreline_AstNode {
22421
23259
  constructor(id,pos,target,targetPos,leadingComments,trailingComments) {
22422
- super(id,pos,leadingComments,trailingComments);
23260
+ loreline_Node._hx_skip_constructor = true;
23261
+ super();
23262
+ loreline_Node._hx_skip_constructor = false;
23263
+ this._hx_constructor(id,pos,target,targetPos,leadingComments,trailingComments);
23264
+ }
23265
+ _hx_constructor(id,pos,target,targetPos,leadingComments,trailingComments) {
23266
+ this.args = null;
23267
+ this.targetExpr = null;
23268
+ super._hx_constructor(id,pos,leadingComments,trailingComments);
22423
23269
  this.target = target;
22424
23270
  this.targetPos = targetPos;
22425
23271
  }
22426
23272
  type() {
22427
23273
  return "Transition";
22428
23274
  }
23275
+ each(handleNode) {
23276
+ super.each(handleNode);
23277
+ if(this.targetExpr != null) {
23278
+ handleNode(this.targetExpr,this);
23279
+ this.targetExpr.each(handleNode);
23280
+ }
23281
+ if(this.args != null) {
23282
+ let _g = 0;
23283
+ let _g1 = this.args;
23284
+ while(_g < _g1.length) {
23285
+ let arg = _g1[_g];
23286
+ ++_g;
23287
+ handleNode(arg,this);
23288
+ arg.each(handleNode);
23289
+ }
23290
+ }
23291
+ }
22429
23292
  toJson() {
22430
23293
  let json = super.toJson();
22431
- json.target = this.target;
23294
+ if(this.targetExpr != null) {
23295
+ json.targetExpr = this.targetExpr.toJson();
23296
+ } else {
23297
+ json.target = this.target;
23298
+ }
22432
23299
  json.targetPos = this.targetPos.toJson();
23300
+ if(this.args != null) {
23301
+ let _g = [];
23302
+ let _g1 = 0;
23303
+ let _g2 = this.args;
23304
+ while(_g1 < _g2.length) {
23305
+ let arg = _g2[_g1];
23306
+ ++_g1;
23307
+ _g.push(arg.toJson());
23308
+ }
23309
+ json.args = _g;
23310
+ }
22433
23311
  return json;
22434
23312
  }
22435
23313
  }
@@ -22441,17 +23319,57 @@ Object.assign(loreline_NTransition.prototype, {
22441
23319
  });
22442
23320
  class loreline_NInsertion extends loreline_AstNode {
22443
23321
  constructor(id,pos,target,targetPos,leadingComments,trailingComments) {
22444
- super(id,pos,leadingComments,trailingComments);
23322
+ loreline_Node._hx_skip_constructor = true;
23323
+ super();
23324
+ loreline_Node._hx_skip_constructor = false;
23325
+ this._hx_constructor(id,pos,target,targetPos,leadingComments,trailingComments);
23326
+ }
23327
+ _hx_constructor(id,pos,target,targetPos,leadingComments,trailingComments) {
23328
+ this.args = null;
23329
+ this.targetExpr = null;
23330
+ super._hx_constructor(id,pos,leadingComments,trailingComments);
22445
23331
  this.target = target;
22446
23332
  this.targetPos = targetPos;
22447
23333
  }
22448
23334
  type() {
22449
23335
  return "Insertion";
22450
23336
  }
23337
+ each(handleNode) {
23338
+ super.each(handleNode);
23339
+ if(this.targetExpr != null) {
23340
+ handleNode(this.targetExpr,this);
23341
+ this.targetExpr.each(handleNode);
23342
+ }
23343
+ if(this.args != null) {
23344
+ let _g = 0;
23345
+ let _g1 = this.args;
23346
+ while(_g < _g1.length) {
23347
+ let arg = _g1[_g];
23348
+ ++_g;
23349
+ handleNode(arg,this);
23350
+ arg.each(handleNode);
23351
+ }
23352
+ }
23353
+ }
22451
23354
  toJson() {
22452
23355
  let json = super.toJson();
22453
- json.target = this.target;
23356
+ if(this.targetExpr != null) {
23357
+ json.targetExpr = this.targetExpr.toJson();
23358
+ } else {
23359
+ json.target = this.target;
23360
+ }
22454
23361
  json.targetPos = this.targetPos.toJson();
23362
+ if(this.args != null) {
23363
+ let _g = [];
23364
+ let _g1 = 0;
23365
+ let _g2 = this.args;
23366
+ while(_g1 < _g2.length) {
23367
+ let arg = _g2[_g1];
23368
+ ++_g1;
23369
+ _g.push(arg.toJson());
23370
+ }
23371
+ json.args = _g;
23372
+ }
22455
23373
  return json;
22456
23374
  }
22457
23375
  }
@@ -22461,6 +23379,63 @@ loreline_NInsertion.__super__ = loreline_AstNode;
22461
23379
  Object.assign(loreline_NInsertion.prototype, {
22462
23380
  __class__: loreline_NInsertion
22463
23381
  });
23382
+ class loreline_NBeatCall extends loreline_AstNode {
23383
+ constructor(id,pos,targetExpr,targetPos,leadingComments,trailingComments) {
23384
+ loreline_Node._hx_skip_constructor = true;
23385
+ super();
23386
+ loreline_Node._hx_skip_constructor = false;
23387
+ this._hx_constructor(id,pos,targetExpr,targetPos,leadingComments,trailingComments);
23388
+ }
23389
+ _hx_constructor(id,pos,targetExpr,targetPos,leadingComments,trailingComments) {
23390
+ this.args = null;
23391
+ super._hx_constructor(id,pos,leadingComments,trailingComments);
23392
+ this.targetExpr = targetExpr;
23393
+ this.targetPos = targetPos;
23394
+ }
23395
+ type() {
23396
+ return "BeatCall";
23397
+ }
23398
+ each(handleNode) {
23399
+ super.each(handleNode);
23400
+ if(this.targetExpr != null) {
23401
+ handleNode(this.targetExpr,this);
23402
+ this.targetExpr.each(handleNode);
23403
+ }
23404
+ if(this.args != null) {
23405
+ let _g = 0;
23406
+ let _g1 = this.args;
23407
+ while(_g < _g1.length) {
23408
+ let arg = _g1[_g];
23409
+ ++_g;
23410
+ handleNode(arg,this);
23411
+ arg.each(handleNode);
23412
+ }
23413
+ }
23414
+ }
23415
+ toJson() {
23416
+ let json = super.toJson();
23417
+ json.targetExpr = this.targetExpr.toJson();
23418
+ json.targetPos = this.targetPos.toJson();
23419
+ if(this.args != null) {
23420
+ let _g = [];
23421
+ let _g1 = 0;
23422
+ let _g2 = this.args;
23423
+ while(_g1 < _g2.length) {
23424
+ let arg = _g2[_g1];
23425
+ ++_g1;
23426
+ _g.push(arg.toJson());
23427
+ }
23428
+ json.args = _g;
23429
+ }
23430
+ return json;
23431
+ }
23432
+ }
23433
+ $hxClasses["loreline.NBeatCall"] = loreline_NBeatCall;
23434
+ loreline_NBeatCall.__name__ = "loreline.NBeatCall";
23435
+ loreline_NBeatCall.__super__ = loreline_AstNode;
23436
+ Object.assign(loreline_NBeatCall.prototype, {
23437
+ __class__: loreline_NBeatCall
23438
+ });
22464
23439
  class loreline_NFunctionDecl extends loreline_NExpr {
22465
23440
  constructor(id,pos,name,args,code,external,leadingComments,trailingComments) {
22466
23441
  super(id,pos,leadingComments,trailingComments);
@@ -22833,7 +23808,9 @@ Object.assign(loreline_NImportStatement.prototype, {
22833
23808
  });
22834
23809
  class loreline_Objects {
22835
23810
  static isFields(value) {
22836
- if(js_Boot.__implements(value,loreline_Fields)) {
23811
+ if(value == null) {
23812
+ return false;
23813
+ } else if(js_Boot.__implements(value,loreline_Fields)) {
22837
23814
  return true;
22838
23815
  } else if(((value) instanceof haxe_ds_StringMap)) {
22839
23816
  return true;
@@ -22934,7 +23911,8 @@ class loreline_Objects {
22934
23911
  }
22935
23912
  return instance;
22936
23913
  }
22937
- return new haxe_ds_StringMap();
23914
+ let fields = { };
23915
+ return fields;
22938
23916
  }
22939
23917
  }
22940
23918
  $hxClasses["loreline.Objects"] = loreline_Objects;
@@ -22968,6 +23946,7 @@ Object.assign(loreline_ParserContext.prototype, {
22968
23946
  });
22969
23947
  class loreline_Parser {
22970
23948
  constructor(tokens,context) {
23949
+ this.parsingCondition = false;
22971
23950
  this.tokens = tokens;
22972
23951
  this.current = 0;
22973
23952
  this.errors = null;
@@ -23061,6 +24040,9 @@ class loreline_Parser {
23061
24040
  if(advanceLineBreaks == null) {
23062
24041
  advanceLineBreaks = true;
23063
24042
  }
24043
+ if(this.parsingCondition) {
24044
+ advanceLineBreaks = false;
24045
+ }
23064
24046
  let prev = this.tokens[this.current];
23065
24047
  if(!this.isAtEnd()) {
23066
24048
  this.lastTokenEnd = prev.pos;
@@ -23323,7 +24305,17 @@ class loreline_Parser {
23323
24305
  case 1:
23324
24306
  return this.parseStateDecl(false);
23325
24307
  case 2:
23326
- return this.parseBeatDecl();
24308
+ if(this.peek().type == loreline_TokenType.LParen) {
24309
+ let node = this.parseBeatCall();
24310
+ if(topLevel) {
24311
+ return _gthis.wrapInRootBeat(node);
24312
+ } else {
24313
+ return node;
24314
+ }
24315
+ } else {
24316
+ return this.parseBeatDecl();
24317
+ }
24318
+ break;
23327
24319
  case 3:
23328
24320
  if(topLevel) {
23329
24321
  return this.parseCharacterDecl();
@@ -23817,6 +24809,34 @@ class loreline_Parser {
23817
24809
  this.expect(loreline_TokenType.KwBeat);
23818
24810
  beatNode.pos = startPos.extendedTo(this.currentPos());
23819
24811
  beatNode.name = this.expectIdentifier();
24812
+ if(this.match(loreline_TokenType.LParen)) {
24813
+ let params = [];
24814
+ if(!this.check(loreline_TokenType.RParen)) {
24815
+ do {
24816
+ while(this.match(loreline_TokenType.LineBreak)) {
24817
+ }
24818
+ let paramPos = this.currentPos();
24819
+ let paramName = this.expectIdentifier();
24820
+ let defaultValue = null;
24821
+ if(this.match(loreline_TokenType.OpAssign)) {
24822
+ defaultValue = this.parseExpression();
24823
+ }
24824
+ let _g = 0;
24825
+ while(_g < params.length) {
24826
+ let existing = params[_g];
24827
+ ++_g;
24828
+ if(existing.name == paramName) {
24829
+ this.addError(new loreline_ParseError("Duplicate beat parameter: " + paramName,paramPos));
24830
+ }
24831
+ }
24832
+ params.push(new loreline_NBeatParam(paramName,paramPos,defaultValue));
24833
+ while(this.match(loreline_TokenType.LineBreak)) {
24834
+ }
24835
+ } while(this.match(loreline_TokenType.Comma));
24836
+ }
24837
+ this.expect(loreline_TokenType.RParen);
24838
+ beatNode.params = params;
24839
+ }
23820
24840
  let blockStart = this.parseBlockStart();
23821
24841
  let blockEnd = blockStart.type == loreline_TokenType.Indent ? loreline_TokenType.Unindent : loreline_TokenType.RBrace;
23822
24842
  beatNode.style = blockEnd == loreline_TokenType.RBrace ? 1 : 0;
@@ -24229,14 +25249,72 @@ class loreline_Parser {
24229
25249
  if(this.match(loreline_TokenType.Dot)) {
24230
25250
  return this.attachComments(new loreline_NTransition(this.nextNodeId(4),startPos.extendedTo(this.prevNonWhitespaceOrComment().pos),".",this.prevNonWhitespaceOrComment().pos));
24231
25251
  }
25252
+ if(this.check(loreline_TokenType.KwBeat)) {
25253
+ let targetStart = this.currentPos();
25254
+ this.advance();
25255
+ this.expect(loreline_TokenType.LParen);
25256
+ let callArgs = this.parseCallArguments();
25257
+ if(callArgs.length == 0) {
25258
+ this.addError(new loreline_ParseError("beat() requires a target expression",targetStart));
25259
+ }
25260
+ let node = new loreline_NTransition(this.nextNodeId(4),startPos.extendedTo(this.prevNonWhitespaceOrComment().pos),null,targetStart.extendedTo(this.prevNonWhitespaceOrComment().pos));
25261
+ node.targetExpr = callArgs.length > 0 ? callArgs[0] : null;
25262
+ if(callArgs.length > 1) {
25263
+ node.args = callArgs.slice(1);
25264
+ }
25265
+ return this.attachComments(node);
25266
+ }
24232
25267
  let target = this.expectIdentifier();
24233
- return this.attachComments(new loreline_NTransition(this.nextNodeId(4),startPos.extendedTo(this.prevNonWhitespaceOrComment().pos),target,this.prevNonWhitespaceOrComment().pos));
25268
+ let targetPos = this.prevNonWhitespaceOrComment().pos;
25269
+ let args = null;
25270
+ if(this.match(loreline_TokenType.LParen)) {
25271
+ args = this.parseCallArguments();
25272
+ }
25273
+ let node = new loreline_NTransition(this.nextNodeId(4),startPos.extendedTo(this.prevNonWhitespaceOrComment().pos),target,targetPos);
25274
+ node.args = args;
25275
+ return this.attachComments(node);
24234
25276
  }
24235
25277
  parseInsertion() {
24236
25278
  let startPos = this.currentPos();
24237
25279
  this.expect(loreline_TokenType.OpPlus);
25280
+ if(this.check(loreline_TokenType.KwBeat)) {
25281
+ let targetStart = this.currentPos();
25282
+ this.advance();
25283
+ this.expect(loreline_TokenType.LParen);
25284
+ let callArgs = this.parseCallArguments();
25285
+ if(callArgs.length == 0) {
25286
+ this.addError(new loreline_ParseError("beat() requires a target expression",targetStart));
25287
+ }
25288
+ let node = new loreline_NInsertion(this.nextNodeId(4),startPos.extendedTo(this.prevNonWhitespaceOrComment().pos),null,targetStart.extendedTo(this.prevNonWhitespaceOrComment().pos));
25289
+ node.targetExpr = callArgs.length > 0 ? callArgs[0] : null;
25290
+ if(callArgs.length > 1) {
25291
+ node.args = callArgs.slice(1);
25292
+ }
25293
+ return this.attachComments(node);
25294
+ }
24238
25295
  let target = this.expectIdentifier();
24239
- return this.attachComments(new loreline_NInsertion(this.nextNodeId(4),startPos.extendedTo(this.prevNonWhitespaceOrComment().pos),target,this.prevNonWhitespaceOrComment().pos));
25296
+ let targetPos = this.prevNonWhitespaceOrComment().pos;
25297
+ let args = null;
25298
+ if(this.match(loreline_TokenType.LParen)) {
25299
+ args = this.parseCallArguments();
25300
+ }
25301
+ let node = new loreline_NInsertion(this.nextNodeId(4),startPos.extendedTo(this.prevNonWhitespaceOrComment().pos),target,targetPos);
25302
+ node.args = args;
25303
+ return this.attachComments(node);
25304
+ }
25305
+ parseBeatCall() {
25306
+ let startPos = this.currentPos();
25307
+ this.expect(loreline_TokenType.KwBeat);
25308
+ this.expect(loreline_TokenType.LParen);
25309
+ let callArgs = this.parseCallArguments();
25310
+ if(callArgs.length == 0) {
25311
+ this.addError(new loreline_ParseError("beat() requires a target expression",startPos));
25312
+ }
25313
+ let node = new loreline_NBeatCall(this.nextNodeId(4),startPos.extendedTo(this.prevNonWhitespaceOrComment().pos),callArgs.length > 0 ? callArgs[0] : null,startPos.extendedTo(this.prevNonWhitespaceOrComment().pos));
25314
+ if(callArgs.length > 1) {
25315
+ node.args = callArgs.slice(1);
25316
+ }
25317
+ return this.attachComments(node);
24240
25318
  }
24241
25319
  parseFunction() {
24242
25320
  let startPos = this.currentPos();
@@ -24872,7 +25950,7 @@ class loreline_Parser {
24872
25950
  elements.push(this.parseExpression());
24873
25951
  }
24874
25952
  let prev = this.previous();
24875
- needsSeparator = prev.type != loreline_TokenType.Colon && prev.type != loreline_TokenType.LineBreak;
25953
+ needsSeparator = prev.type != loreline_TokenType.Colon && prev.type != loreline_TokenType.LineBreak && prev.type != loreline_TokenType.Unindent;
24876
25954
  }
24877
25955
  while(this.match(loreline_TokenType.LineBreak) || this.match(loreline_TokenType.Indent) || this.match(loreline_TokenType.Unindent)) {
24878
25956
  }
@@ -24905,7 +25983,7 @@ class loreline_Parser {
24905
25983
  fields.push(this.parseObjectField());
24906
25984
  }
24907
25985
  let prev = this.previous();
24908
- needsSeparator = prev.type != loreline_TokenType.Colon && prev.type != loreline_TokenType.LineBreak;
25986
+ needsSeparator = prev.type != loreline_TokenType.Colon && prev.type != loreline_TokenType.LineBreak && prev.type != loreline_TokenType.Unindent;
24909
25987
  }
24910
25988
  while(this.match(loreline_TokenType.LineBreak) || blockEnd != loreline_TokenType.Unindent && this.match(loreline_TokenType.Unindent)) {
24911
25989
  }
@@ -24928,6 +26006,8 @@ class loreline_Parser {
24928
26006
  return args;
24929
26007
  }
24930
26008
  parseConditionExpression() {
26009
+ let prevParsingCondition = this.parsingCondition;
26010
+ this.parsingCondition = true;
24931
26011
  let hasParen = this.match(loreline_TokenType.LParen);
24932
26012
  let expr = null;
24933
26013
  try {
@@ -24947,6 +26027,7 @@ class loreline_Parser {
24947
26027
  throw _g;
24948
26028
  }
24949
26029
  }
26030
+ this.parsingCondition = prevParsingCondition;
24950
26031
  if(hasParen) {
24951
26032
  this.expect(loreline_TokenType.RParen);
24952
26033
  }
@@ -25418,6 +26499,9 @@ class loreline_Printer {
25418
26499
  case loreline_NAssign:
25419
26500
  this.printAssignment(node);
25420
26501
  break;
26502
+ case loreline_NBeatCall:
26503
+ this.printBeatCall(node);
26504
+ break;
25421
26505
  case loreline_NBeatDecl:
25422
26506
  this.printBeatDecl(node);
25423
26507
  break;
@@ -25631,7 +26715,29 @@ class loreline_Printer {
25631
26715
  this.newline();
25632
26716
  this.newline();
25633
26717
  this.printLeadingComments(beat);
25634
- this.write("beat " + beat.name + " ");
26718
+ this.write("beat " + beat.name);
26719
+ if(beat.params != null) {
26720
+ let savedComments = this.enableComments;
26721
+ this.enableComments = false;
26722
+ this.write("(");
26723
+ let _g = 0;
26724
+ let _g1 = beat.params.length;
26725
+ while(_g < _g1) {
26726
+ let i = _g++;
26727
+ if(i > 0) {
26728
+ this.write(", ");
26729
+ }
26730
+ let param = beat.params[i];
26731
+ this.write(param.name);
26732
+ if(param.defaultValue != null) {
26733
+ this.write(" = ");
26734
+ this.printNode(param.defaultValue);
26735
+ }
26736
+ }
26737
+ this.write(")");
26738
+ this.enableComments = savedComments;
26739
+ }
26740
+ this.write(" ");
25635
26741
  this.printTrailingComments(beat);
25636
26742
  if(beat.style == 1) {
25637
26743
  this.write("{");
@@ -25936,7 +27042,18 @@ class loreline_Printer {
25936
27042
  this.newline();
25937
27043
  }
25938
27044
  this.printLeadingComments(trans);
25939
- this.write("-> " + trans.target);
27045
+ if(trans.targetExpr != null) {
27046
+ this.write("-> beat(");
27047
+ this.printTargetExprAndArgs(trans.targetExpr,trans.args);
27048
+ this.write(")");
27049
+ } else {
27050
+ this.write("-> " + trans.target);
27051
+ if(trans.args != null) {
27052
+ this.write("(");
27053
+ this.printTargetExprAndArgs(null,trans.args);
27054
+ this.write(")");
27055
+ }
27056
+ }
25940
27057
  this.printTrailingComments(trans);
25941
27058
  }
25942
27059
  printInsertion(insert) {
@@ -25944,9 +27061,52 @@ class loreline_Printer {
25944
27061
  this.newline();
25945
27062
  }
25946
27063
  this.printLeadingComments(insert);
25947
- this.write("+ " + insert.target);
27064
+ if(insert.targetExpr != null) {
27065
+ this.write("+ beat(");
27066
+ this.printTargetExprAndArgs(insert.targetExpr,insert.args);
27067
+ this.write(")");
27068
+ } else {
27069
+ this.write("+ " + insert.target);
27070
+ if(insert.args != null) {
27071
+ this.write("(");
27072
+ this.printTargetExprAndArgs(null,insert.args);
27073
+ this.write(")");
27074
+ }
27075
+ }
25948
27076
  this.printTrailingComments(insert);
25949
27077
  }
27078
+ printBeatCall(call) {
27079
+ if(this._prevLevel == this._level) {
27080
+ this.newline();
27081
+ }
27082
+ this.printLeadingComments(call);
27083
+ this.write("beat(");
27084
+ this.printTargetExprAndArgs(call.targetExpr,call.args);
27085
+ this.write(")");
27086
+ this.printTrailingComments(call);
27087
+ }
27088
+ printTargetExprAndArgs(targetExpr,args) {
27089
+ let savedComments = this.enableComments;
27090
+ this.enableComments = false;
27091
+ let first = true;
27092
+ if(targetExpr != null) {
27093
+ this.printNode(targetExpr);
27094
+ first = false;
27095
+ }
27096
+ if(args != null) {
27097
+ let _g = 0;
27098
+ while(_g < args.length) {
27099
+ let arg = args[_g];
27100
+ ++_g;
27101
+ if(!first) {
27102
+ this.write(", ");
27103
+ }
27104
+ first = false;
27105
+ this.printNode(arg);
27106
+ }
27107
+ }
27108
+ this.enableComments = savedComments;
27109
+ }
25950
27110
  printStringLiteral(str) {
25951
27111
  let surroundWithQuotes = str.quotes == 1;
25952
27112
  if(surroundWithQuotes) {
@@ -26614,9 +27774,84 @@ class loreline_Utf8 {
26614
27774
  static uCharAt(str,pos) {
26615
27775
  return str.charAt(pos);
26616
27776
  }
27777
+ static toCodes(str) {
27778
+ let len = str.length;
27779
+ let v = new Array(len);
27780
+ let _g = 0;
27781
+ let _g1 = len;
27782
+ while(_g < _g1) {
27783
+ let i = _g++;
27784
+ v[i] = str.charCodeAt(i);
27785
+ }
27786
+ return v;
27787
+ }
26617
27788
  }
26618
27789
  $hxClasses["loreline.Utf8"] = loreline_Utf8;
26619
27790
  loreline_Utf8.__name__ = "loreline.Utf8";
27791
+ class loreline_Utf8Vector {
27792
+ static uLength(v) {
27793
+ return v.length;
27794
+ }
27795
+ static uCharCodeAt(v,pos) {
27796
+ if(pos < 0 || pos >= v.length) {
27797
+ return -1;
27798
+ } else {
27799
+ return v[pos];
27800
+ }
27801
+ }
27802
+ static uSubstr(v,pos,len) {
27803
+ return loreline_Utf8Vector.slice(v,pos,len != null ? pos + len : v.length);
27804
+ }
27805
+ static uSubstring(v,startIndex,endIndex) {
27806
+ return loreline_Utf8Vector.slice(v,startIndex,endIndex != null ? endIndex : v.length);
27807
+ }
27808
+ static uCharAt(v,pos) {
27809
+ if(pos < 0 || pos >= v.length) {
27810
+ return "";
27811
+ } else {
27812
+ return loreline_Utf8Vector.slice(v,pos,pos + 1);
27813
+ }
27814
+ }
27815
+ static uIndexOf(v,substr,startIndex) {
27816
+ let needle = loreline_Utf8.toCodes(substr);
27817
+ let nlen = needle.length;
27818
+ if(nlen == 0) {
27819
+ if(startIndex != null) {
27820
+ return startIndex;
27821
+ } else {
27822
+ return 0;
27823
+ }
27824
+ }
27825
+ let i = startIndex != null && startIndex > 0 ? startIndex : 0;
27826
+ let last = v.length - nlen;
27827
+ while(i <= last) {
27828
+ let k = 0;
27829
+ while(k < nlen && v[i + k] == needle[k]) ++k;
27830
+ if(k == nlen) {
27831
+ return i;
27832
+ }
27833
+ ++i;
27834
+ }
27835
+ return -1;
27836
+ }
27837
+ static slice(v,start,end) {
27838
+ if(start < 0) {
27839
+ start = 0;
27840
+ }
27841
+ if(end > v.length) {
27842
+ end = v.length;
27843
+ }
27844
+ let buf_b = "";
27845
+ let i = start;
27846
+ while(i < end) {
27847
+ buf_b += String.fromCodePoint(v[i]);
27848
+ ++i;
27849
+ }
27850
+ return buf_b;
27851
+ }
27852
+ }
27853
+ $hxClasses["loreline.Utf8Vector"] = loreline_Utf8Vector;
27854
+ loreline_Utf8Vector.__name__ = "loreline.Utf8Vector";
26620
27855
  class loreline_WrappedError extends loreline_Error {
26621
27856
  constructor(wrapped,message,pos) {
26622
27857
  super(message,pos);
@@ -30342,9 +31577,9 @@ class loreline_lorscript_Interp {
30342
31577
  if(Object.prototype.hasOwnProperty.call(this.interpreter.topLevelFunctions.h,id)) {
30343
31578
  return this.interpreter.topLevelFunctions.h[id];
30344
31579
  }
30345
- let beat = this.interpreter.resolveBeatByName(id);
30346
- if(beat != null) {
30347
- return beat;
31580
+ let beatRef = this.interpreter.resolveBeatRefByName(id);
31581
+ if(beatRef != null) {
31582
+ return beatRef;
30348
31583
  }
30349
31584
  let e = new loreline_lorscript_Error(loreline_lorscript_ErrorDef.EUnknownVariable(id),this.curExpr.pmin,this.curExpr.pmax,this.curExpr.origin,this.curExpr.line);
30350
31585
  throw haxe_Exception.thrown(e);
@@ -30446,16 +31681,25 @@ class loreline_lorscript_Interp {
30446
31681
  args.push(this.expr(p));
30447
31682
  }
30448
31683
  let _g3 = e7.e;
30449
- if(_g3._hx_index == 5) {
30450
- let e = _g3.e;
30451
- let f = _g3.f;
30452
- let obj = this.expr(e);
31684
+ switch(_g3._hx_index) {
31685
+ case 1:
31686
+ let id1 = _g3.v;
31687
+ if(id1 == "call" && !this.callIsShadowed()) {
31688
+ return this.dynamicCall(args);
31689
+ } else {
31690
+ return this.call(null,this.expr(e7),args);
31691
+ }
31692
+ break;
31693
+ case 5:
31694
+ let e8 = _g3.e;
31695
+ let f2 = _g3.f;
31696
+ let obj = this.expr(e8);
30453
31697
  if(obj == null) {
30454
- let e = new loreline_lorscript_Error(loreline_lorscript_ErrorDef.EInvalidAccess(f),this.curExpr.pmin,this.curExpr.pmax,this.curExpr.origin,this.curExpr.line);
31698
+ let e = new loreline_lorscript_Error(loreline_lorscript_ErrorDef.EInvalidAccess(f2),this.curExpr.pmin,this.curExpr.pmax,this.curExpr.origin,this.curExpr.line);
30455
31699
  throw haxe_Exception.thrown(e);
30456
31700
  }
30457
- return this.fcall(obj,f,args);
30458
- } else {
31701
+ return this.fcall(obj,f2,args);
31702
+ default:
30459
31703
  return this.call(null,this.expr(e7),args);
30460
31704
  }
30461
31705
  break;
@@ -30473,14 +31717,14 @@ class loreline_lorscript_Interp {
30473
31717
  break;
30474
31718
  case 10:
30475
31719
  let econd1 = e1.cond;
30476
- let e8 = e1.e;
30477
- this.whileLoop(econd1,e8);
31720
+ let e9 = e1.e;
31721
+ this.whileLoop(econd1,e9);
30478
31722
  return null;
30479
31723
  case 11:
30480
31724
  let v2 = e1.v;
30481
31725
  let it = e1.it;
30482
- let e9 = e1.e;
30483
- this.forLoop(v2,it,e9);
31726
+ let e10 = e1.e;
31727
+ this.forLoop(v2,it,e10);
30484
31728
  return null;
30485
31729
  case 12:
30486
31730
  throw haxe_Exception.thrown(loreline_lorscript__$Interp_Stop.SBreak);
@@ -30505,7 +31749,7 @@ class loreline_lorscript_Interp {
30505
31749
  minParams += 1;
30506
31750
  }
30507
31751
  }
30508
- let f2 = function(args) {
31752
+ let f3 = function(args) {
30509
31753
  if((args == null ? 0 : args.length) != params1.length) {
30510
31754
  if(args.length < minParams) {
30511
31755
  let str = "Invalid number of parameters. Got " + args.length + ", required " + minParams;
@@ -30565,26 +31809,26 @@ class loreline_lorscript_Interp {
30565
31809
  me.depth = depth;
30566
31810
  return r;
30567
31811
  };
30568
- let f3 = Reflect.makeVarArgs(f2);
31812
+ let f4 = Reflect.makeVarArgs(f3);
30569
31813
  if(name != null) {
30570
31814
  if(this.depth == 0) {
30571
- this.variables.h[name] = f3;
31815
+ this.variables.h[name] = f4;
30572
31816
  } else {
30573
31817
  this.declared.push({ n : name, old : this.locals.h[name]});
30574
- let ref = { r : f3};
31818
+ let ref = { r : f4};
30575
31819
  this.locals.h[name] = ref;
30576
31820
  capturedLocals.h[name] = ref;
30577
31821
  }
30578
31822
  }
30579
- return f3;
31823
+ return f4;
30580
31824
  case 15:
30581
- let e10 = e1.e;
30582
- this.returnValue = e10 == null ? null : this.expr(e10);
31825
+ let e13 = e1.e;
31826
+ this.returnValue = e13 == null ? null : this.expr(e13);
30583
31827
  throw haxe_Exception.thrown(loreline_lorscript__$Interp_Stop.SReturn);
30584
31828
  case 16:
30585
- let e13 = e1.e;
31829
+ let e14 = e1.e;
30586
31830
  let index = e1.index;
30587
- let arr = this.expr(e13);
31831
+ let arr = this.expr(e14);
30588
31832
  let index1 = this.expr(index);
30589
31833
  if(loreline_Arrays.isArray(arr)) {
30590
31834
  return loreline_Arrays.arrayGet(arr,index1);
@@ -30658,18 +31902,18 @@ class loreline_lorscript_Interp {
30658
31902
  }
30659
31903
  return this.cnew(cl,a);
30660
31904
  case 19:
30661
- let e14 = e1.e;
30662
- throw haxe_Exception.thrown(this.expr(e14));
31905
+ let e15 = e1.e;
31906
+ throw haxe_Exception.thrown(this.expr(e15));
30663
31907
  case 20:
30664
31908
  let _g7 = e1.t;
30665
- let e15 = e1.e;
31909
+ let e16 = e1.e;
30666
31910
  let n1 = e1.v;
30667
31911
  let ecatch = e1.ecatch;
30668
31912
  let old1 = this.declared.length;
30669
31913
  let oldTry = this.inTry;
30670
31914
  try {
30671
31915
  this.inTry = true;
30672
- let v = this.expr(e15);
31916
+ let v = this.expr(e16);
30673
31917
  this.restore(old1);
30674
31918
  this.inTry = oldTry;
30675
31919
  return v;
@@ -30703,19 +31947,19 @@ class loreline_lorscript_Interp {
30703
31947
  return o;
30704
31948
  case 22:
30705
31949
  let econd2 = e1.cond;
30706
- let e16 = e1.e1;
31950
+ let e17 = e1.e1;
30707
31951
  let e23 = e1.e2;
30708
31952
  if(this.expr(econd2) == true) {
30709
- return this.expr(e16);
31953
+ return this.expr(e17);
30710
31954
  } else {
30711
31955
  return this.expr(e23);
30712
31956
  }
30713
31957
  break;
30714
31958
  case 23:
30715
- let e17 = e1.e;
31959
+ let e18 = e1.e;
30716
31960
  let cases = e1.cases;
30717
31961
  let def = e1.defaultExpr;
30718
- let val = this.expr(e17);
31962
+ let val = this.expr(e18);
30719
31963
  let match = false;
30720
31964
  let _g9 = 0;
30721
31965
  while(_g9 < cases.length) {
@@ -30742,18 +31986,18 @@ class loreline_lorscript_Interp {
30742
31986
  return val;
30743
31987
  case 24:
30744
31988
  let econd3 = e1.cond;
30745
- let e18 = e1.e;
30746
- this.doWhileLoop(econd3,e18);
31989
+ let e19 = e1.e;
31990
+ this.doWhileLoop(econd3,e19);
30747
31991
  return null;
30748
31992
  case 25:
30749
31993
  let _g10 = e1.name;
30750
31994
  let _g11 = e1.args;
30751
- let e19 = e1.e;
30752
- return this.expr(e19);
30753
- case 26:
30754
- let _g12 = e1.t;
30755
31995
  let e20 = e1.e;
30756
31996
  return this.expr(e20);
31997
+ case 26:
31998
+ let _g12 = e1.t;
31999
+ let e24 = e1.e;
32000
+ return this.expr(e24);
30757
32001
  }
30758
32002
  }
30759
32003
  doWhileLoop(econd,e) {
@@ -30992,17 +32236,18 @@ class loreline_lorscript_Interp {
30992
32236
  }
30993
32237
  fcall(o,f,args) {
30994
32238
  let helper = null;
32239
+ let oBeat = loreline_RuntimeBeatRef.beatOf(o);
30995
32240
  if(typeof(o) == "string") {
30996
32241
  helper = loreline_Objects.getStringHelper(this.interpreter,f);
30997
32242
  } else if(loreline_Arrays.isArray(o)) {
30998
32243
  helper = loreline_Objects.getArrayHelper(this.interpreter,f);
30999
- } else if(((o) instanceof loreline_NBeatDecl)) {
32244
+ } else if(oBeat != null) {
31000
32245
  helper = loreline_Objects.getBeatHelper(this.interpreter,f);
31001
32246
  } else if(loreline_Objects.isFields(o)) {
31002
32247
  helper = loreline_Objects.getMapHelper(this.interpreter,f);
31003
32248
  }
31004
32249
  if(helper != null && Reflect.isFunction(helper)) {
31005
- args.splice(0,0,o);
32250
+ args.splice(0,0,oBeat != null ? oBeat : o);
31006
32251
  return this.call(null,helper,args);
31007
32252
  }
31008
32253
  return this.call(o,this.get(o,f),args);
@@ -31010,6 +32255,57 @@ class loreline_lorscript_Interp {
31010
32255
  call(o,f,args) {
31011
32256
  return f.apply(o,args);
31012
32257
  }
32258
+ callIsShadowed() {
32259
+ if(Object.prototype.hasOwnProperty.call(this.locals.h,"call")) {
32260
+ return true;
32261
+ }
32262
+ if(Object.prototype.hasOwnProperty.call(this.variables.h,"call")) {
32263
+ return true;
32264
+ }
32265
+ if(loreline_Objects.fieldExists(this.interpreter,this.interpreter.topLevelState.fields,"call")) {
32266
+ return true;
32267
+ }
32268
+ if(Object.prototype.hasOwnProperty.call(this.interpreter.topLevelCharacters.h,"call")) {
32269
+ return true;
32270
+ }
32271
+ if(Object.prototype.hasOwnProperty.call(this.interpreter.topLevelFunctions.h,"call")) {
32272
+ return true;
32273
+ }
32274
+ if(this.interpreter.resolveBeatByName("call") != null) {
32275
+ return true;
32276
+ }
32277
+ return false;
32278
+ }
32279
+ dynamicCall(args) {
32280
+ if(args.length == 0) {
32281
+ let e = new loreline_lorscript_Error(loreline_lorscript_ErrorDef.ECustom("call() requires a target argument"),this.curExpr.pmin,this.curExpr.pmax,this.curExpr.origin,this.curExpr.line);
32282
+ throw haxe_Exception.thrown(e);
32283
+ }
32284
+ let target = args[0];
32285
+ let rest = args.slice(1);
32286
+ if(loreline_RuntimeBeatRef.beatOf(target) != null) {
32287
+ let e = new loreline_lorscript_Error(loreline_lorscript_ErrorDef.ECustom("call() can only call functions. Beats cannot run inside function code."),this.curExpr.pmin,this.curExpr.pmax,this.curExpr.origin,this.curExpr.line);
32288
+ throw haxe_Exception.thrown(e);
32289
+ }
32290
+ if(typeof(target) == "string") {
32291
+ let name = target;
32292
+ if(this.interpreter.resolveBeatByName(name) != null) {
32293
+ let e = new loreline_lorscript_Error(loreline_lorscript_ErrorDef.ECustom("call() can only call functions. Beats cannot run inside function code."),this.curExpr.pmin,this.curExpr.pmax,this.curExpr.origin,this.curExpr.line);
32294
+ throw haxe_Exception.thrown(e);
32295
+ }
32296
+ if(Object.prototype.hasOwnProperty.call(this.interpreter.topLevelFunctions.h,name)) {
32297
+ target = this.interpreter.topLevelFunctions.h[name];
32298
+ } else {
32299
+ let e = new loreline_lorscript_Error(loreline_lorscript_ErrorDef.ECustom("call() target not found: " + name),this.curExpr.pmin,this.curExpr.pmax,this.curExpr.origin,this.curExpr.line);
32300
+ throw haxe_Exception.thrown(e);
32301
+ }
32302
+ }
32303
+ if(!Reflect.isFunction(target)) {
32304
+ let e = new loreline_lorscript_Error(loreline_lorscript_ErrorDef.ECustom("call() target is not a function"),this.curExpr.pmin,this.curExpr.pmax,this.curExpr.origin,this.curExpr.line);
32305
+ throw haxe_Exception.thrown(e);
32306
+ }
32307
+ return this.call(null,target,rest);
32308
+ }
31013
32309
  cnew(cl,args) {
31014
32310
  let c = $hxClasses[cl];
31015
32311
  if(c == null) {
@@ -35728,15 +37024,16 @@ class loreline_translation_CsvTranslation {
35728
37024
  let field = new StringBuf();
35729
37025
  let inQuotes = false;
35730
37026
  let i = 0;
35731
- let len = content.length;
37027
+ let chars = content;
37028
+ let len = chars.length;
35732
37029
  while(i < len) {
35733
- let c = HxOverrides.cca(content,i);
37030
+ let c = HxOverrides.cca(chars,i);
35734
37031
  let c1 = c == null ? -1 : c;
35735
37032
  if(inQuotes) {
35736
37033
  if(c1 == 34) {
35737
37034
  let tmp;
35738
37035
  if(i + 1 < len) {
35739
- let c = HxOverrides.cca(content,i + 1);
37036
+ let c = HxOverrides.cca(chars,i + 1);
35740
37037
  tmp = (c == null ? -1 : c) == 34;
35741
37038
  } else {
35742
37039
  tmp = false;
@@ -35768,7 +37065,7 @@ class loreline_translation_CsvTranslation {
35768
37065
  row = [];
35769
37066
  let tmp;
35770
37067
  if(c1 == 13 && i + 1 < len) {
35771
- let c = HxOverrides.cca(content,i + 1);
37068
+ let c = HxOverrides.cca(chars,i + 1);
35772
37069
  tmp = (c == null ? -1 : c) == 10;
35773
37070
  } else {
35774
37071
  tmp = false;
@@ -36290,18 +37587,14 @@ class loreline_translation_XliffTranslation {
36290
37587
  let _g_array = root.children;
36291
37588
  while(_g_current < _g_array.length) {
36292
37589
  let child = _g_array[_g_current++];
36293
- let tmp;
36294
37590
  if(child.nodeType == 0) {
36295
37591
  if(child.nodeType != Xml.Element) {
36296
37592
  throw haxe_Exception.thrown("Bad node type, expected Element but found " + (child.nodeType == null ? "null" : XmlType.toString(child.nodeType)));
36297
37593
  }
36298
- tmp = child.nodeName == "xliff";
36299
- } else {
36300
- tmp = false;
36301
- }
36302
- if(tmp) {
36303
- xliff = child;
36304
- break;
37594
+ if(child.nodeName == "xliff") {
37595
+ xliff = child;
37596
+ break;
37597
+ }
36305
37598
  }
36306
37599
  }
36307
37600
  if(xliff == null) {
@@ -36428,17 +37721,13 @@ class loreline_translation_XliffTranslation {
36428
37721
  let _g_array = parent.children;
36429
37722
  while(_g_current < _g_array.length) {
36430
37723
  let c = _g_array[_g_current++];
36431
- let tmp;
36432
37724
  if(c.nodeType == 0) {
36433
37725
  if(c.nodeType != Xml.Element) {
36434
37726
  throw haxe_Exception.thrown("Bad node type, expected Element but found " + (c.nodeType == null ? "null" : XmlType.toString(c.nodeType)));
36435
37727
  }
36436
- tmp = c.nodeName == name;
36437
- } else {
36438
- tmp = false;
36439
- }
36440
- if(tmp) {
36441
- return c;
37728
+ if(c.nodeName == name) {
37729
+ return c;
37730
+ }
36442
37731
  }
36443
37732
  }
36444
37733
  return null;