Ver código fonte

Implemented missing methods.

Matthias 9 anos atrás
pai
commit
2434317b6d

+ 0 - 1
src/MusicalScore/InstrumentalGroup.ts

@@ -10,7 +10,6 @@ export class InstrumentalGroup {
     private musicSheet: MusicSheet;
     private parent: InstrumentalGroup;
     private instrumentalGroups: InstrumentalGroup[] = [];
-    //private instruments: List<Instrument> = new List<Instrument>();
     public get InstrumentalGroups(): InstrumentalGroup[] {
         return this.instrumentalGroups;
     }

+ 38 - 35
src/MusicalScore/MusicSheet.ts

@@ -13,6 +13,9 @@ import {Voice} from "./VoiceData/Voice";
 import {MusicSheetErrors} from "../Common/DataObjects/MusicSheetErrors";
 import {MultiTempoExpression} from "./VoiceData/Expressions/multiTempoExpression";
 import {EngravingRules} from "./Graphical/EngravingRules";
+import {NoteState} from "./Graphical/DrawingEnums";
+import {Note} from "./VoiceData/Note";
+import {VoiceEntry} from "./VoiceData/VoiceEntry";
 
 // FIXME
 //type MusicSheetParameters = any;
@@ -47,7 +50,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public pageWidth: number;
     public rules: EngravingRules;
 
-    //private idString: string = "kjgdfuilhsda�oihfsvjh";
+    private idString: string = "kjgdfuilhsdaöoihfsvjh";
     private sourceMeasures: SourceMeasure[] = [];
     private repetitions: Repetition[] = [];
     private dynListStaves: DynamicsContainer[][] = [];
@@ -74,7 +77,7 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     private hasBeenOpenedForTheFirstTime: boolean = false;
     private currentEnrolledPosition: Fraction = new Fraction(0, 1);
     // (*) private musicSheetParameterObject: MusicSheetParameterObject = undefined;
-    // (*) private engravingRules: EngravingRules;
+    private engravingRules: EngravingRules;
     // (*) private musicSheetParameterChangedDelegate: MusicSheetParameterChangedDelegate;
 
     public static getIndexFromStaff(staff: Staff): number {
@@ -197,12 +200,12 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public set Lyricist(value: Label) {
         this.lyricist = value;
     }
-    // (*) public get Rules(): EngravingRules {
-    //    return this.engravingRules;
-    //}
-    // (*) public set Rules(value: EngravingRules) {
-    //    this.engravingRules = value;
-    //}
+    public get Rules(): EngravingRules {
+       return this.engravingRules;
+    }
+    public set Rules(value: EngravingRules) {
+       this.engravingRules = value;
+    }
     public get SheetErrors(): MusicSheetErrors {
         return this.musicSheetErrors;
     }
@@ -289,19 +292,19 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     public getLastSourceMeasure(): SourceMeasure {
         return this.sourceMeasures[this.sourceMeasures.length - 1];
     }
-    // (*) public resetAllNoteStates(): void {
-    //    let iterator: MusicPartManagerIterator = this.MusicPartManager.getIterator();
-    //    while (!iterator.EndReached && iterator.CurrentVoiceEntries !== undefined) {
-    //        for (let idx: number = 0, len: number = iterator.CurrentVoiceEntries.length; idx < len; ++idx) {
-    //            let voiceEntry: VoiceEntry = iterator.CurrentVoiceEntries[idx];
-    //            for (let idx2: number = 0, len2: number = voiceEntry.Notes.length; idx2 < len2; ++idx2) {
-    //                let note: Note = voiceEntry.Notes[idx2];
-    //                note.State = NoteState.Normal;
-    //            }
-    //        }
-    //        iterator.moveToNext();
-    //    }
-    //}
+    public resetAllNoteStates(): void {
+       let iterator: MusicPartManagerIterator = this.MusicPartManager.getIterator();
+       while (!iterator.EndReached && iterator.CurrentVoiceEntries !== undefined) {
+           for (let idx: number = 0, len: number = iterator.CurrentVoiceEntries.length; idx < len; ++idx) {
+               let voiceEntry: VoiceEntry = iterator.CurrentVoiceEntries[idx];
+               for (let idx2: number = 0, len2: number = voiceEntry.Notes.length; idx2 < len2; ++idx2) {
+                   let note: Note = voiceEntry.Notes[idx2];
+                   note.state = NoteState.Normal;
+               }
+           }
+           iterator.moveToNext();
+       }
+    }
     public getMusicSheetInstrumentIndex(instrument: Instrument): number {
         return this.Instruments.indexOf(instrument);
     }
@@ -436,22 +439,22 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
     //public set MusicSheetParameterChanged(value: MusicSheetParameterChangedDelegate) {
     //    this.musicSheetParameterChangedDelegate = value;
     //}
-    //public get FullNameString(): string {
-    //    return this.ComposerString + " " + this.TitleString;
-    //}
-    //public get IdString(): string {
-    //    return this.idString;
-    //}
-    //public set IdString(value: string) {
-    //    this.idString = value;
-    //}
-    //public Dispose(): void {
+    public get FullNameString(): string {
+       return this.ComposerString + " " + this.TitleString;
+    }
+    public get IdString(): string {
+       return this.idString;
+    }
+    public set IdString(value: string) {
+       this.idString = value;
+    }
+    // public Dispose(): void {
     //    this.MusicSheetParameterChanged = undefined;
-    //    for (let idx: number = 0, len: number = this.IInstruments.length; idx < len; ++idx) {
-    //        let instrument: IInstrument = this.IInstruments[idx];
-    //        instrument.Dispose(); // FIXME
+    //    for (let idx: number = 0, len: number = this.instruments.length; idx < len; ++idx) {
+    //        let instrument: Instrument = this.instruments[idx];
+    //        instrument.dispose(); // FIXME
     //    }
-    //}
+    // }
     public getEnrolledSelectionStartTimeStampWorkaround(): Fraction {
         let iter: MusicPartManagerIterator = this.MusicPartManager.getIterator(this.SelectionStart);
         return Fraction.createFromFraction(iter.CurrentEnrolledTimestamp);

+ 55 - 58
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -19,7 +19,7 @@ import {IXmlAttribute} from "../../Common/FileIO/Xml";
 import {ChordSymbolContainer} from "../VoiceData/ChordSymbolContainer";
 import {Logging} from "../../Common/logging";
 import {MidiInstrument} from "../VoiceData/Instructions/ClefInstruction";
-
+import Dictionary from "typescript-collections/dist/lib/Dictionary";
 
 // FIXME: The following classes are missing
 //type repetitionInstructionReader = any;
@@ -78,7 +78,7 @@ export class InstrumentReader {
   private activeRhythm: RhythmInstruction;
   private activeClefsHaveBeenInitialized: boolean[];
   private activeKeyHasBeenInitialized: boolean = false;
-  private abstractInstructions: { [n: number]: AbstractNotationInstruction; } = {};
+  private abstractInstructions: Dictionary<number, AbstractNotationInstruction> = new Dictionary<number, AbstractNotationInstruction>();
   private openChordSymbolContainer: ChordSymbolContainer;
   // (*) private expressionReaders: ExpressionReader[];
   private currentVoiceGenerator: VoiceGenerator;
@@ -706,85 +706,81 @@ export class InstrumentReader {
   }
 
   private saveAbstractInstructionList(numberOfStaves: number, beginOfMeasure: boolean): void {
-    // FIXME TODO
-    // Logging.debug("saveAbstractInstructionList still to implement! See InstrumentReader.ts");
-  }
-
-  /*private saveAbstractInstructionList(numberOfStaves: number, beginOfMeasure: boolean): void {
-    for (let i: number = this.abstractInstructions.length - 1; i >= 0; i--) {
-      let keyValuePair: KeyValuePairClass<number, AbstractNotationInstruction> = this.abstractInstructions[i];
-      if (keyValuePair.value instanceof ClefInstruction) {
-        let clefInstruction: ClefInstruction = <ClefInstruction>keyValuePair.value;
-        if (this.currentXmlMeasureIndex === 0 || (keyValuePair.key <= this.activeClefs.length && clefInstruction !== this.activeClefs[keyValuePair.key - 1])) {
-          if (!beginOfMeasure && this.currentStaffEntry !== undefined && !this.currentStaffEntry.hasNotes() && keyValuePair.key - 1
-          === this.instrument.Staves.IndexOf(this.currentStaffEntry.ParentStaff)) {
+    for (let i: number = this.abstractInstructions.keys().length - 1; i >= 0; i--) {
+      let key: number = this.abstractInstructions.keys()[i];
+      let value: AbstractNotationInstruction = this.abstractInstructions.getValue(key);
+      if (value instanceof ClefInstruction) {
+        let clefInstruction: ClefInstruction = <ClefInstruction>value;
+        if (this.currentXmlMeasureIndex === 0 || (key <= this.activeClefs.length && clefInstruction !== this.activeClefs[key - 1])) {
+          if (!beginOfMeasure && this.currentStaffEntry !== undefined && !this.currentStaffEntry.hasNotes() && key - 1
+          === this.instrument.Staves.indexOf(this.currentStaffEntry.ParentStaff)) {
             let newClefInstruction: ClefInstruction = clefInstruction;
             newClefInstruction.Parent = this.currentStaffEntry;
             this.currentStaffEntry.removeFirstInstructionOfType<ClefInstruction>();
-            this.currentStaffEntry.Instructions.Add(newClefInstruction);
-            this.activeClefs[keyValuePair.key - 1] = clefInstruction;
-            this.abstractInstructions.Remove(keyValuePair);
+            this.currentStaffEntry.Instructions.push(newClefInstruction);
+            this.activeClefs[key - 1] = clefInstruction;
+            this.abstractInstructions.remove(key);
           } else if (beginOfMeasure) {
             let firstStaffEntry: SourceStaffEntry;
             if (this.currentMeasure !== undefined) {
               let newClefInstruction: ClefInstruction = clefInstruction;
               if (this.currentXmlMeasureIndex === 0) {
-                if (this.currentMeasure.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + keyValuePair.key - 1] === undefined) {
+                if (this.currentMeasure.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + key - 1] === undefined) {
                   firstStaffEntry = new SourceStaffEntry(undefined, undefined);
-                  this.currentMeasure.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + keyValuePair.key - 1] = firstStaffEntry;
+                  this.currentMeasure.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + key - 1] = firstStaffEntry;
                   newClefInstruction.Parent = firstStaffEntry;
-                  firstStaffEntry.Instructions.Add(newClefInstruction);
-                  this.activeClefsHaveBeenInitialized[keyValuePair.key - 1] = true;
-                } else if (this.currentMeasure.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + keyValuePair.key - 1]
+                  firstStaffEntry.Instructions.push(newClefInstruction);
+                  this.activeClefsHaveBeenInitialized[key - 1] = true;
+                } else if (this.currentMeasure.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + key - 1]
                 !==
-                undefined && !(this.currentMeasure.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + keyValuePair.key - 1].Instructions[0]
+                undefined && !(this.currentMeasure.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + key - 1].Instructions[0]
                  instanceof ClefInstruction)) {
-                  firstStaffEntry = this.currentMeasure.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + keyValuePair.key - 1];
+                  firstStaffEntry = this.currentMeasure.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + key - 1];
                   newClefInstruction.Parent = firstStaffEntry;
                   firstStaffEntry.removeFirstInstructionOfType<ClefInstruction>();
-                  firstStaffEntry.Instructions.Insert(0, newClefInstruction);
-                  this.activeClefsHaveBeenInitialized[keyValuePair.key - 1] = true;
+                  firstStaffEntry.Instructions.splice(0, 0, newClefInstruction);
+                  this.activeClefsHaveBeenInitialized[key - 1] = true;
                 } else {
-                  firstStaffEntry = new SourceStaffEntry(undefined, undefined);
-                  this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + keyValuePair.key - 1] = lastStaffEntry;
+                  let lastStaffEntry: SourceStaffEntry = new SourceStaffEntry(undefined, undefined);
+                  this.currentMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + key - 1] = lastStaffEntry;
                   newClefInstruction.Parent = lastStaffEntry;
-                  lastStaffEntry.Instructions.Add(newClefInstruction);
+                  lastStaffEntry.Instructions.push(newClefInstruction);
                 }
-              } else if (!this.activeClefsHaveBeenInitialized[keyValuePair.key - 1]) {
-                let first: SourceMeasure = this.musicSheet2.SourceMeasures[0];
-                if (first.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + keyValuePair.key - 1] === undefined) {
+              } else if (!this.activeClefsHaveBeenInitialized[key - 1]) {
+                let first: SourceMeasure = this.musicSheet.SourceMeasures[0];
+                if (first.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + key - 1] === undefined) {
                   firstStaffEntry = new SourceStaffEntry(undefined, undefined);
                 } else {
-                  firstStaffEntry = first.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + keyValuePair.key - 1];
+                  firstStaffEntry = first.FirstInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + key - 1];
                   firstStaffEntry.removeFirstInstructionOfType<ClefInstruction>();
                 }
                 newClefInstruction.Parent = firstStaffEntry;
-                firstStaffEntry.Instructions.Insert(0, newClefInstruction);
-                this.activeClefsHaveBeenInitialized[keyValuePair.key - 1] = true;
+                firstStaffEntry.Instructions.splice(0, 0, newClefInstruction);
+                this.activeClefsHaveBeenInitialized[key - 1] = true;
               } else {
                 let lastStaffEntry: SourceStaffEntry = new SourceStaffEntry(undefined, undefined);
-                this.previousMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + keyValuePair.key - 1] = lastStaffEntry;
+                this.previousMeasure.LastInstructionsStaffEntries[this.inSourceMeasureInstrumentIndex + key - 1] = lastStaffEntry;
                 newClefInstruction.Parent = lastStaffEntry;
-                lastStaffEntry.Instructions.Add(newClefInstruction);
+                lastStaffEntry.Instructions.push(newClefInstruction);
               }
-              this.activeClefs[keyValuePair.key - 1] = clefInstruction;
-              this.abstractInstructions.Remove(keyValuePair);
+              this.activeClefs[key - 1] = clefInstruction;
+              this.abstractInstructions.remove(key);
             }
           }
         }
-        if (keyValuePair.key <= this.activeClefs.length && clefInstruction === this.activeClefs[keyValuePair.key - 1])
-          this.abstractInstructions.Remove(keyValuePair);
+        if (key <= this.activeClefs.length && clefInstruction === this.activeClefs[key - 1])
+          this.abstractInstructions.remove(key);
       }
-      if (keyValuePair.value instanceof KeyInstruction) {
-        let keyInstruction: KeyInstruction = <KeyInstruction>keyValuePair.value;
+      if (value instanceof KeyInstruction) {
+        let keyInstruction: KeyInstruction = <KeyInstruction>value;
         if (this.activeKey === undefined || this.activeKey.Key !== keyInstruction.Key) {
           this.activeKey = keyInstruction;
-          this.abstractInstructions.Remove(keyValuePair);
+          this.abstractInstructions.remove(key);
           let sourceMeasure: SourceMeasure;
           if (!this.activeKeyHasBeenInitialized) {
             this.activeKeyHasBeenInitialized = true;
             if (this.currentXmlMeasureIndex > 0) {
-              sourceMeasure = this.musicSheet2.SourceMeasures[0];
+              sourceMeasure = this.musicSheet.SourceMeasures[0];
             } else {
               sourceMeasure = this.currentMeasure;
             }
@@ -795,21 +791,21 @@ export class InstrumentReader {
             for (let j: number = this.inSourceMeasureInstrumentIndex; j < this.inSourceMeasureInstrumentIndex + numberOfStaves; j++) {
               let newKeyInstruction: KeyInstruction = keyInstruction;
               if (sourceMeasure.FirstInstructionsStaffEntries[j] === undefined) {
-                firstStaffEntry = new SourceStaffEntry(undefined, undefined);
+                let firstStaffEntry: SourceStaffEntry = new SourceStaffEntry(undefined, undefined);
                 sourceMeasure.FirstInstructionsStaffEntries[j] = firstStaffEntry;
                 newKeyInstruction.Parent = firstStaffEntry;
-                firstStaffEntry.Instructions.Add(newKeyInstruction);
+                firstStaffEntry.Instructions.push(newKeyInstruction);
               } else {
-                firstStaffEntry = sourceMeasure.FirstInstructionsStaffEntries[j];
+                let firstStaffEntry: SourceStaffEntry = sourceMeasure.FirstInstructionsStaffEntries[j];
                 newKeyInstruction.Parent = firstStaffEntry;
                 firstStaffEntry.removeFirstInstructionOfTypeKeyInstruction();
                 if (firstStaffEntry.Instructions.length === 0) {
-                  firstStaffEntry.Instructions.Add(newKeyInstruction);
+                  firstStaffEntry.Instructions.push(newKeyInstruction);
                 } else {
                   if (firstStaffEntry.Instructions[0] instanceof ClefInstruction) {
-                    firstStaffEntry.Instructions.Insert(1, newKeyInstruction);
+                    firstStaffEntry.Instructions.splice(1, 0, newKeyInstruction);
                   } else {
-                    firstStaffEntry.Instructions.Insert(0, newKeyInstruction);
+                    firstStaffEntry.Instructions.splice(0, 0, newKeyInstruction);
                   }
                 }
               }
@@ -817,16 +813,17 @@ export class InstrumentReader {
           }
         }
         if (this.activeKey !== undefined && this.activeKey === keyInstruction)
-          this.abstractInstructions.Remove(keyValuePair);
+          this.abstractInstructions.remove(key);
       }
-      if (keyValuePair.value instanceof RhythmInstruction) {
-        let rhythmInstruction: RhythmInstruction = <RhythmInstruction>keyValuePair.value;
+      if (value instanceof RhythmInstruction) {
+        let rhythmInstruction: RhythmInstruction = <RhythmInstruction>value;
         if (this.activeRhythm === undefined || this.activeRhythm !== rhythmInstruction) {
           this.activeRhythm = rhythmInstruction;
-          this.abstractInstructions.Remove(keyValuePair);
+          this.abstractInstructions.remove(key);
           if (this.currentMeasure !== undefined) {
             for (let j: number = this.inSourceMeasureInstrumentIndex; j < this.inSourceMeasureInstrumentIndex + numberOfStaves; j++) {
               let newRhythmInstruction: RhythmInstruction = rhythmInstruction;
+              let firstStaffEntry: SourceStaffEntry;
               if (this.currentMeasure.FirstInstructionsStaffEntries[j] === undefined) {
                 firstStaffEntry = new SourceStaffEntry(undefined, undefined);
                 this.currentMeasure.FirstInstructionsStaffEntries[j] = firstStaffEntry;
@@ -835,16 +832,16 @@ export class InstrumentReader {
                 firstStaffEntry.removeFirstInstructionOfType<RhythmInstruction>();
               }
               newRhythmInstruction.Parent = firstStaffEntry;
-              firstStaffEntry.Instructions.Add(newRhythmInstruction);
+              firstStaffEntry.Instructions.push(newRhythmInstruction);
             }
           }
         }
         if (this.activeRhythm !== undefined && this.activeRhythm === rhythmInstruction)
-          this.abstractInstructions.Remove(keyValuePair);
+          this.abstractInstructions.remove(key);
       }
     }
   }
-  */
+
   private saveClefInstructionAtEndOfMeasure(): void {
     for (let key in this.abstractInstructions) {
       if (this.abstractInstructions.hasOwnProperty(key)) {

+ 2 - 2
src/MusicalScore/SubInstrument.ts

@@ -17,7 +17,7 @@ export class SubInstrument {
         "clarinet": MidiInstrument.Clarinet,
         "klarinette": MidiInstrument.Clarinet,
         "flute": MidiInstrument.Flute,
-        "flte": MidiInstrument.Flute,
+        "flöte": MidiInstrument.Flute,
         "frenchhorn": MidiInstrument.French_Horn,
         "guitar": MidiInstrument.Acoustic_Guitar_nylon,
         "gitarre": MidiInstrument.Acoustic_Guitar_nylon,
@@ -55,7 +55,7 @@ export class SubInstrument {
         "sopran": MidiInstrument.Synth_Voice,
         "voice": MidiInstrument.Synth_Voice,
         "recorder": MidiInstrument.Recorder,
-        "blockflte": MidiInstrument.Recorder,
+        "blockflöte": MidiInstrument.Recorder,
         "banjo": MidiInstrument.Banjo,
         "drums": MidiInstrument.Percussion,
         "percussion": MidiInstrument.Percussion,

+ 2 - 1
src/MusicalScore/VoiceData/Note.ts

@@ -7,6 +7,7 @@ import {Tuplet} from "./Tuplet";
 import {Tie} from "./Tie";
 import {Staff} from "./Staff";
 import {Slur} from "./Expressions/ContinuousExpressions/Slur";
+import {NoteState} from "../Graphical/DrawingEnums";
 
 // import Vex = require("vexflow");
 
@@ -25,7 +26,7 @@ export class Note {
     }
 
     public halfTone: number;
-
+    public state: NoteState;
     private voiceEntry: VoiceEntry;
     private parentStaffEntry: SourceStaffEntry;
     private length: Fraction;

+ 22 - 22
src/MusicalScore/VoiceData/SourceStaffEntry.ts

@@ -20,8 +20,6 @@ export class SourceStaffEntry {
   private voiceEntries: VoiceEntry[] = [];
   private staffEntryLink: StaffEntryLink;
   private instructions: AbstractNotationInstruction[] = [];
-  //private graceVoiceEntriesBefore: VoiceEntry[] = [];
-  //private graceVoiceEntriesAfter: VoiceEntry[] = [];
   private chordSymbolContainer: ChordSymbolContainer;
   public get ParentStaff(): Staff {
     return this.parentStaff;
@@ -65,26 +63,28 @@ export class SourceStaffEntry {
   public set ChordContainer(value: ChordSymbolContainer) {
     this.chordSymbolContainer = value;
   }
-  //public removeAllInstructionsOfType<T>(): number {
-  //  let i: number = 0;
-  //  let ret: number = 0;
-  //  while (i < this.instructions.length) {
-  //    if (this.instructions[i] instanceof T) {
-  //      this.instructions.splice(i, 1);
-  //      ret++;
-  //    } else { i++; }
-  //  }
-  //  return ret;
-  //}
-  //public removeFirstInstructionOfType<T>(): boolean {
-  //  for (let i: number = 0; i < this.instructions.length; i++) {
-  //    if (this.instructions[i] instanceof T) {
-  //      this.instructions.splice(i, 1);
-  //      return true;
-  //    }
-  //  }
-  //  return false;
-  //}
+  public removeAllInstructionsOfType<T>(): number {
+   let i: number = 0;
+   let ret: number = 0;
+   while (i < this.instructions.length) {
+       let instruction: Object = this.instructions[i];
+       if (<T>instruction !== undefined) {
+           this.instructions.splice(i, 1);
+           ret++;
+       }  else { i++; }
+   }
+   return ret;
+  }
+  public removeFirstInstructionOfType<T>(): boolean {
+   for (let i: number = 0; i < this.instructions.length; i++) {
+       let instruction: Object = this.instructions[i];
+       if (<T>instruction !== undefined) {
+          this.instructions.splice(i, 1);
+          return true;
+       }
+   }
+   return false;
+  }
   public removeAllInstructionsOfTypeClefInstruction(): number {
     let i: number = 0;
     let ret: number = 0;