Skip to content

Commit fa91a72

Browse files
committed
getLineNumberedSource improvements
1 parent 84ccf8e commit fa91a72

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

demo/minimal.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@
9393
for(let f=0;f<k;f++){const h=d.getActiveUniform(b,f);a.push({name:h.name,location:d.getUniformLocation(b,
9494
h.name)})}return{v:d.getAttribLocation(b,"V"),m:a,l:c?(f,h)=>c.l(f,h):()=>{},i:(f,
9595
h)=>{d.useProgram(b);f();c?(f=c.g,c.g=c.h,c.h=f,c.i(h)):h()}}}
96-
function V(a){a=a.split(/r?n/);const b=a.length.toString().length,c=[];a.forEach((d,
97-
k)=>{var f=c.push;k=""+(k+1);k=k.length>=b?k:" ".repeat(b-k.length)+k;f.call(c,k+
98-
":");c.push(d);c.push("n")});return c.join("")}
9996
function J(a,b,c,d){a=a.gl;c=a.createShader(c);a.shaderSource(c,d);a.compileShader(c);
10097
if(!a.getShaderParameter(c,a.COMPILE_STATUS)){const k=String(a.getShaderInfoLog(c));
10198
a.deleteShader(c);b="Cannot compile shader - "+b+": "+k;console.log(b);console.log(V(d));

dist/shader-web-background.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/shader-web-background.min.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/js/webgl-utils.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@ const padLineNumber = (str, targetLength) =>
138138
? str
139139
: " ".repeat(targetLength - str.length) + str;
140140

141+
/**
142+
* @param {!string} source
143+
* @return {!string} line numbered source
144+
*/
145+
function getLineNumberedSource(source) {
146+
const lines = source.split(/\r?\n/);
147+
const maxDigits = lines.length.toString().length;
148+
var buffer = [];
149+
lines.forEach((line, index) => {
150+
const lineNumber = padLineNumber((index + 1).toString(), maxDigits);
151+
buffer.push(lineNumber + ": " + line + "\n");
152+
});
153+
return buffer.join("");
154+
}
155+
156+
141157
/**
142158
* @template T
143159
*/
@@ -187,22 +203,6 @@ class GlWrapper {
187203
this.textureCount = 0;
188204
}
189205

190-
/**
191-
* @param {!string} source
192-
* @return {!string} numbered source
193-
*/
194-
getLineNumberedSource(source) {
195-
const lines = source.split(/\r?\n/);
196-
const maxDigits = lines.length.toString().length;
197-
const buffer = [];
198-
lines.forEach((line, index) => {
199-
buffer.push(padLineNumber("" + (index + 1), maxDigits) + ":");
200-
buffer.push(line);
201-
buffer.push("\n");
202-
});
203-
return buffer.join("");
204-
}
205-
206206
/**
207207
* @param {!string} id
208208
* @param {!number} type
@@ -219,7 +219,7 @@ class GlWrapper {
219219
gl.deleteShader(shader);
220220
const message = "Cannot compile shader - " + id + ": " + info;
221221
console.log(message);
222-
console.log(this.getLineNumberedSource(source));
222+
console.log(getLineNumberedSource(source));
223223
throw new Error(message);
224224
}
225225
return shader;

0 commit comments

Comments
 (0)