shaderCodeCursor.ts 970 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /** @hidden */
  2. export class ShaderCodeCursor {
  3. private _lines: string[];
  4. lineIndex: number;
  5. get currentLine(): string {
  6. return this._lines[this.lineIndex];
  7. }
  8. get canRead(): boolean {
  9. return this.lineIndex < this._lines.length - 1;
  10. }
  11. set lines(value: string[]) {
  12. this._lines = [];
  13. for (var line of value) {
  14. // Prevent removing line break in macros.
  15. if (line[0] === "#") {
  16. this._lines.push(line);
  17. continue;
  18. }
  19. const split = line.split(";");
  20. for (var index = 0; index < split.length; index++) {
  21. let subLine = split[index];
  22. subLine = subLine.trim();
  23. if (!subLine) {
  24. continue;
  25. }
  26. this._lines.push(subLine + (index !== split.length - 1 ? ";" : ""));
  27. }
  28. }
  29. }
  30. }