Skip to content

Commit

Permalink
refactor(shader-ast): update imports
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Feb 24, 2020
1 parent 6dbea7d commit ff6eb70
Show file tree
Hide file tree
Showing 23 changed files with 108 additions and 108 deletions.
8 changes: 4 additions & 4 deletions packages/shader-ast/src/api/function.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Fn,
Fn0,
Fn2,
Expand All @@ -9,9 +9,9 @@ import {
Fn7,
Fn8
} from "@thi.ng/api";
import { FnCall, Sym, Term } from "./nodes";
import { SymOpts } from "./syms";
import { Type } from "./types";
import type { FnCall, Sym, Term } from "./nodes";
import type { SymOpts } from "./syms";
import type { Type } from "./types";

export type ScopeBody = (Term<any> | null | undefined)[];

Expand Down
12 changes: 6 additions & 6 deletions packages/shader-ast/src/api/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Func0,
Func1,
Func2,
Expand All @@ -9,11 +9,11 @@ import {
Func7,
Func8
} from "./function";
import { Operator } from "./ops";
import { SymOpts } from "./syms";
import { Tag } from "./tags";
import { BoolTerm } from "./terms";
import {
import type { Operator } from "./ops";
import type { SymOpts } from "./syms";
import type { Tag } from "./tags";
import type { BoolTerm } from "./terms";
import type {
Assignable,
Indexable,
Type,
Expand Down
4 changes: 2 additions & 2 deletions packages/shader-ast/src/api/syms.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Sym } from "./nodes";
import { Precision } from "./precision";
import type { Sym } from "./nodes";
import type { Precision } from "./precision";

export type SymQualifier = "in" | "out" | "inout";

Expand Down
6 changes: 3 additions & 3 deletions packages/shader-ast/src/api/target.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Fn } from "@thi.ng/api";
import {
import type { Fn } from "@thi.ng/api";
import type {
ArrayInit,
Assign,
Branch,
Expand All @@ -19,7 +19,7 @@ import {
Ternary,
WhileLoop
} from "./nodes";
import { Tag } from "./tags";
import type { Tag } from "./tags";

export interface TargetImpl<T> extends Record<Tag, Fn<any, T>> {
arg: Fn<FuncArg<any>, T>;
Expand Down
2 changes: 1 addition & 1 deletion packages/shader-ast/src/api/terms.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Term } from "./nodes";
import type { Term } from "./nodes";

export type BoolTerm = Term<"bool">;
export type FloatTerm = Term<"float">;
Expand Down
4 changes: 2 additions & 2 deletions packages/shader-ast/src/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Index, Swizzle, Sym } from "./nodes";
import {
import type { Index, Swizzle, Sym } from "./nodes";
import type {
BoolTerm,
FloatTerm,
IntTerm,
Expand Down
4 changes: 2 additions & 2 deletions packages/shader-ast/src/ast/assign.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from "@thi.ng/api";
import { Assign, Swizzle, Term } from "../api/nodes";
import { Assignable, Type } from "../api/types";
import type { Assign, Swizzle, Term } from "../api/nodes";
import type { Assignable, Type } from "../api/types";

export const assign = <L extends Type, R extends L>(
l: Assignable<L>,
Expand Down
2 changes: 1 addition & 1 deletion packages/shader-ast/src/ast/checks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Term } from "../api/nodes";
import type { Term } from "../api/nodes";

const RE_VEC = /^[iub]?vec[234]$/;
const RE_MAT = /^mat[234]$/;
Expand Down
12 changes: 6 additions & 6 deletions packages/shader-ast/src/ast/controlflow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FnBody1 } from "..";
import { Fn } from "@thi.ng/api";
import {
import { decl, scope } from "./scope";
import type { FnBody1 } from "../api/function";
import type { Fn } from "@thi.ng/api";
import type {
Branch,
ControlFlow,
ForLoop,
Expand All @@ -9,9 +10,8 @@ import {
Ternary,
WhileLoop
} from "../api/nodes";
import { BoolTerm } from "../api/terms";
import { Type } from "../api/types";
import { decl, scope } from "./scope";
import type { BoolTerm } from "../api/terms";
import type { Type } from "../api/types";

export const ifThen = (
test: BoolTerm,
Expand Down
22 changes: 11 additions & 11 deletions packages/shader-ast/src/ast/function.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { assert } from "@thi.ng/api";
import { isString } from "@thi.ng/checks";
import { gensym } from "./idgen";
import {
allChildren,
scope,
scopedChildren,
walk
} from "./scope";
import { sym } from "./sym";
import type {
Arg,
Arg1,
Arg2,
Expand All @@ -21,7 +29,7 @@ import {
FnBody8,
ScopeBody
} from "../api/function";
import {
import type {
FnCall,
Func,
FuncArg,
Expand All @@ -38,16 +46,8 @@ import {
TaggedFn8,
Term
} from "../api/nodes";
import { SymOpts } from "../api/syms";
import { Type } from "../api/types";
import { gensym } from "./idgen";
import {
allChildren,
scope,
scopedChildren,
walk
} from "./scope";
import { sym } from "./sym";
import type { SymOpts } from "../api/syms";
import type { Type } from "../api/types";

const defArg = <T extends Type>(a: Arg<T>): FuncArg<T> => {
const [type, id, opts] = isString(a) ? <[T, string?, SymOpts?]>[a] : a;
Expand Down
8 changes: 4 additions & 4 deletions packages/shader-ast/src/ast/indexed.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { isNumber } from "@thi.ng/checks";
import { Index, Sym } from "../api/nodes";
import { UintTerm } from "../api/terms";
import {
import { int } from "./lit";
import type { Index, Sym } from "../api/nodes";
import type { UintTerm } from "../api/terms";
import type {
Indexable,
IndexTypeMap,
MatIndexTypeMap,
NumericI
} from "../api/types";
import { int } from "./lit";

export const index = <T extends Indexable>(
val: Sym<T>,
Expand Down
20 changes: 10 additions & 10 deletions packages/shader-ast/src/ast/item.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
import { IObjectOf } from "@thi.ng/api";
import { Term } from "../api/nodes";
import { FloatTerm } from "../api/terms";
import {
Int,
IVec,
Prim,
Type,
UVec
} from "../api/types";
import {
bool,
float,
Expand All @@ -17,6 +7,16 @@ import {
vec3,
vec4
} from "./lit";
import type { IObjectOf } from "@thi.ng/api";
import type { Term } from "../api/nodes";
import type { FloatTerm } from "../api/terms";
import type {
Int,
IVec,
Prim,
Type,
UVec
} from "../api/types";

/**
* Returns base type for given term. Used for array ops.
Expand Down
10 changes: 5 additions & 5 deletions packages/shader-ast/src/ast/lit.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { Fn } from "@thi.ng/api";
import { isBoolean, isNumber } from "@thi.ng/checks";
import { Lit, Term } from "../api/nodes";
import {
import { isVec } from "./checks";
import type { Fn } from "@thi.ng/api";
import type { Lit, Term } from "../api/nodes";
import type {
FloatTerm,
IntTerm,
UintTerm,
Vec2Term,
Vec3Term,
Vec4Term
} from "../api/terms";
import {
import type {
NumericB,
NumericF,
NumericI,
NumericU,
Type
} from "../api/types";
import { isVec } from "./checks";

export const lit = <T extends Type>(
type: T,
Expand Down
16 changes: 8 additions & 8 deletions packages/shader-ast/src/ast/ops.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { IObjectOf } from "@thi.ng/api";
import { isNumber } from "@thi.ng/checks";
import {
import { isMat, isVec } from "./checks";
import { numberWithMatchingType } from "./item";
import { float } from "./lit";
import type { IObjectOf } from "@thi.ng/api";
import type {
Op1,
Op2,
Sym,
Term
} from "../api/nodes";
import { ComparisonOperator, Operator } from "../api/ops";
import {
import type { ComparisonOperator, Operator } from "../api/ops";
import type {
BoolTerm,
FloatTerm,
IntTerm,
Expand All @@ -19,7 +22,7 @@ import {
Vec3Term,
Vec4Term
} from "../api/terms";
import {
import type {
Comparable,
Int,
IVec,
Expand All @@ -29,9 +32,6 @@ import {
UVec,
Vec
} from "../api/types";
import { isMat, isVec } from "./checks";
import { numberWithMatchingType } from "./item";
import { float } from "./lit";

export const op1 = <T extends Type>(
op: Operator,
Expand Down
8 changes: 4 additions & 4 deletions packages/shader-ast/src/ast/scope.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Fn, Fn2 } from "@thi.ng/api";
import { isArray } from "@thi.ng/checks";
import { DGraph } from "@thi.ng/dgraph";
import {
import { isMat, isVec } from "./checks";
import type { Fn, Fn2 } from "@thi.ng/api";
import type {
Assign,
Branch,
Decl,
Expand All @@ -16,8 +17,7 @@ import {
Term,
Ternary
} from "../api/nodes";
import { Type } from "../api/types";
import { isMat, isVec } from "./checks";
import type { Type } from "../api/types";

/**
* Helper function for {@link walk}. Returns child nodes for any control
Expand Down
10 changes: 5 additions & 5 deletions packages/shader-ast/src/ast/swizzle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Select4 } from "@thi.ng/api";
import { Swizzle, Term } from "../api/nodes";
import {
import type { Select4 } from "@thi.ng/api";
import type { Swizzle, Term } from "../api/nodes";
import type {
Swizzle2,
Swizzle2_1,
Swizzle2_2,
Expand All @@ -14,7 +14,7 @@ import {
Swizzle4_2,
Swizzle4_3
} from "../api/swizzles";
import {
import type {
BVec2Term,
BVec3Term,
BVec4Term,
Expand All @@ -28,7 +28,7 @@ import {
Vec3Term,
Vec4Term
} from "../api/terms";
import {
import type {
BVec,
IVec,
Type,
Expand Down
6 changes: 3 additions & 3 deletions packages/shader-ast/src/ast/sym.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { assert } from "@thi.ng/api";
import { isString } from "@thi.ng/checks";
import { illegalArgs } from "@thi.ng/errors";
import { Lit, Sym, Term } from "../api/nodes";
import { SymOpts } from "../api/syms";
import { ArrayTypeMap, Type } from "../api/types";
import { gensym } from "./idgen";
import type { Lit, Sym, Term } from "../api/nodes";
import type { SymOpts } from "../api/syms";
import type { ArrayTypeMap, Type } from "../api/types";

export function sym<T extends Type>(init: Term<T>): Sym<T>;
export function sym<T extends Type>(type: T): Sym<T>;
Expand Down
4 changes: 2 additions & 2 deletions packages/shader-ast/src/builtin/bvec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FnCall, Term } from "../api/nodes";
import { BVec } from "../api/types";
import { builtinCall } from "../ast/function";
import type { FnCall, Term } from "../api/nodes";
import type { BVec } from "../api/types";

const $bvec = (t: string) => <any>("bvec" + t[t.length - 1]);

Expand Down
10 changes: 5 additions & 5 deletions packages/shader-ast/src/builtin/math.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { FnCall, Sym, Term } from "../api/nodes";
import {
import { builtinCall } from "../ast/function";
import { matchingBoolType, matchingPrimFor } from "../ast/item";
import type { FnCall, Sym, Term } from "../api/nodes";
import type {
BoolTerm,
BVec2Term,
BVec3Term,
Expand All @@ -17,9 +19,7 @@ import {
Vec3Term,
Vec4Term
} from "../api/terms";
import { Mat, Prim, Vec } from "../api/types";
import { builtinCall } from "../ast/function";
import { matchingBoolType, matchingPrimFor } from "../ast/item";
import type { Mat, Prim, Vec } from "../api/types";

const primOp1 = (name: string) => <T extends Prim>(a: Term<T>) =>
builtinCall(name, a.type, a);
Expand Down
Loading

0 comments on commit ff6eb70

Please sign in to comment.