Skip to content

Commit

Permalink
fix warnings (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
sritchie authored Feb 17, 2022
1 parent fe42b3f commit 2d63f9d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 35 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shadergraph",
"version": "2.1.1",
"version": "2.1.2",
"description": "GLSL linker",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions src/factory/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export class Factory {
}

// Make subgraph and connect to tail
_isolate(sub, main) {
_isolate(sub, _main) {
if (sub.nodes.length) {
let block;
const subgraph = this._subgraph(sub);
Expand All @@ -239,7 +239,7 @@ export class Factory {
}

// Convert to callback and connect to tail
_callback(sub, main) {
_callback(sub, _main) {
if (sub.nodes.length) {
let block;
const subgraph = this._subgraph(sub);
Expand Down
15 changes: 2 additions & 13 deletions src/glsl/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

export const compile = function (program) {
const { ast, code, signatures } = program;
const { code, signatures } = program;

// Prepare list of placeholders
const placeholders = replaced(signatures);
Expand All @@ -21,17 +21,6 @@ export const compile = function (program) {
return [signatures, assembler];
};

// #####

const tick = function () {
const now = +new Date();
return function (label) {
const delta = +new Date() - now;
console.log(label, delta + " ms");
return delta;
};
};

var replaced = function (signatures) {
const out = {};
const s = (sig) => (out[sig.name] = true);
Expand Down Expand Up @@ -70,7 +59,7 @@ var string_compiler = function (code, placeholders) {

// Strip comments
code = code.replace(/\/\/[^\n]*/g, "");
code = code.replace(/\/\*([^*]|\*[^\/])*\*\//g, "");
code = code.replace(/\/\*([^*]|\*[^/])*\*\//g, "");

// Strip all preprocessor commands (lazy)
//code = code.replace /^#[^\n]*/mg, ''
Expand Down
9 changes: 3 additions & 6 deletions src/glsl/decl.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { Vector2 } from "three/src/math/Vector2.js";
import { Vector3 } from "three/src/math/Vector3.js";
import { Vector4 } from "three/src/math/Vector3.js";
import { Vector4 } from "three/src/math/Vector4.js";
import { Matrix3 } from "three/src/math/Matrix3.js";
import { Matrix4 } from "three/src/math/Matrix4.js";

Expand Down Expand Up @@ -37,7 +37,6 @@ decl.external = function (node) {
let c = node.children;

let storage = get(c[1]);
const struct = get(c[3]);
const type = get(c[4]);
const list = c[5];

Expand Down Expand Up @@ -74,7 +73,6 @@ decl.function = function (node) {
// console.log 'function', node

const storage = get(c[1]);
const struct = get(c[3]);
const type = get(c[4]);
const func = c[5];
const ident = get(func.children[0]);
Expand Down Expand Up @@ -229,15 +227,14 @@ class Definition {
}

copy(name, meta) {
let def;
return (def = new Definition(
return new Definition(
name != null ? name : this.name,
this.type,
this.spec,
this.param,
this.value,
this.inout,
meta
));
);
}
}
10 changes: 4 additions & 6 deletions src/glsl/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export function same(a, b) {
export function call(lookup, dangling, entry, signature, body) {
const args = [];
let ret = "";
const rets = 1;

for (let arg of Array.from(signature)) {
var id, shadow;
Expand All @@ -99,7 +98,6 @@ export function call(lookup, dangling, entry, signature, body) {
let other = null;
let meta = null;
let omit = false;
const { inout } = arg;

const isReturn = name === $.RETURN_ARG;

Expand Down Expand Up @@ -178,7 +176,6 @@ export function build(body, calls) {
// Check if we're only calling one snippet with identical signature
// and not building void main();
if (calls && calls.length === 1 && entry !== "main") {
const a = body;
const b = calls[0].module;

if (same(body.signature, b.main.signature)) {
Expand Down Expand Up @@ -304,7 +301,8 @@ export const link = (link, out) => {

// Build wrapper function for the calling side
const outer = body();
const wrapper = call(_lookup, _dangling, entry, external.signature, outer);
call(_lookup, _dangling, entry, external.signature, outer);

outer.calls = inner.calls;
outer.entry = name;

Expand All @@ -317,7 +315,7 @@ export function defuse(code) {
// Don't try this at home kids
const re =
/([A-Za-z0-9_]+\s+)?[A-Za-z0-9_]+\s+[A-Za-z0-9_]+\s*\([^)]*\)\s*;\s*/gm;
const strip = (code) => code.replace(re, (m) => "");
const strip = (code) => code.replace(re, (_m) => "");

// Split into scopes by braces
const blocks = code.split(/(?=[{}])/g);
Expand Down Expand Up @@ -366,7 +364,7 @@ export function dedupe(code) {
const map = {};
const re =
/((attribute|uniform|varying)\s+)[A-Za-z0-9_]+\s+([A-Za-z0-9_]+)\s*(\[[^\]]*\]\s*)?;\s*/gm;
return code.replace(re, function (m, qual, type, name, struct) {
return code.replace(re, function (m, qual, type, name, _struct) {
if (map[name]) {
return "";
}
Expand Down
5 changes: 2 additions & 3 deletions src/graph/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Node {
static initClass() {
this.index = 0;
}
static id(name) {
static id(_name) {
return ++Node.index;
}

Expand Down Expand Up @@ -176,7 +176,7 @@ export class Node {
}

// Disconnect entire node
disconnect(node) {
disconnect(_node) {
let outlet;
for (outlet of Array.from(this.inputs)) {
outlet.disconnect();
Expand Down Expand Up @@ -233,7 +233,6 @@ export class Node {
// Remove outlet object from node.
_remove(outlet) {
const key = this._key(outlet);
const { inout } = outlet;

// Sanity checks
if (outlet.node !== this) {
Expand Down
2 changes: 1 addition & 1 deletion src/visualize/markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var _activate = function (el) {
popup.parentNode.classList.add("shadergraph-has-code");
return popup.parentNode.addEventListener(
"click",
(event) =>
(_event) =>
(popup.style.display = {
block: "none",
none: "block",
Expand Down
2 changes: 0 additions & 2 deletions src/visualize/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// Dump graph for debug/visualization purposes
import * as Block from "../block";

const isCallback = (outlet) => outlet.type[0] === "(";

export var serialize = function (graph) {
const nodes = [];
const links = [];
Expand Down

0 comments on commit 2d63f9d

Please sign in to comment.