factor: removing multiline

locals-and-roots
Doug Coleman 2016-06-22 00:21:23 -07:00
parent 6ab7214185
commit 6ca59c8e02
13 changed files with 63 additions and 66 deletions

View File

@ -1,5 +1,5 @@
USING: math math.parser sequences sequences.private kernel
bit-arrays make io math.ranges multiline fry locals ;
bit-arrays make io math.ranges fry locals ;
IN: benchmark.nsieve-bits
: clear-flags ( step i seq -- )

View File

@ -2,7 +2,7 @@ USING: tools.test alien.syntax specialized-arrays sequences
alien accessors kernel arrays combinators compiler
compiler.units classes.struct combinators.smart
compiler.tree.debugger math libc destructors sequences.private
multiline eval words vocabs namespaces assocs prettyprint
eval words vocabs namespaces assocs prettyprint
alien.data math.vectors definitions compiler.test ;
FROM: specialized-arrays.private => specialized-array-vocab ;
FROM: alien.c-types => int float bool uchar char float ulonglong ushort uint

View File

@ -1,8 +1,8 @@
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: words words.symbol sequences vocabs kernel
compiler.units multiline ;
in: bootstrap.syntax
compiler.units ;
IN: bootstrap.syntax
[
"syntax" create-vocab drop

View File

@ -1,7 +1,7 @@
USING: assocs classes classes.private compiler.units definitions
eval generic io.streams.string kernel math multiline namespaces
parser sequences sets sorting tools.test vocabs words ;
in: classes.tests
IN: classes.tests
{ t } [ 3 object instance? ] unit-test
{ t } [ 3 fixnum instance? ] unit-test
@ -26,11 +26,10 @@ M: method-forget-class method-forget-test ;
] unit-test
! Long-standing problem
use: multiline
! So the user has some code...
{ } [
"in: classes.test.a
"IN: classes.test.a
GENERIC: g ( a -- b ) ;
TUPLE: x ;
M: x g ;
@ -40,16 +39,16 @@ use: multiline
! Note that q inlines M: x g ;
{ } [
"in: classes.test.b
use: classes.test.a
use: kernel
"IN: classes.test.b
USE: classes.test.a
USE: kernel
: q ( -- b ) z new g ;" <string-reader>
"class-intersect-no-method-b" parse-stream drop
] unit-test
! Now, the user removes the z class and adds a method,
{ } [
"in: classes.test.a
"IN: classes.test.a
GENERIC: g ( a -- b ) ;
TUPLE: x ;
M: x g ;
@ -60,17 +59,17 @@ use: multiline
! And changes the definition of q
{ } [
"in: classes.test.b
use: classes.test.a
use: kernel
"IN: classes.test.b
USE: classes.test.a
USE: kernel
: q ( -- b ) j new g ;" <string-reader>
"class-intersect-no-method-b" parse-stream drop
] unit-test
! Similar problem, but with anonymous classes
{ } [
"in: classes.test.c
use: kernel
"IN: classes.test.c
USE: kernel
GENERIC: g ( a -- b ) ;
M: object g ;
TUPLE: z ;" <string-reader>
@ -78,17 +77,17 @@ use: multiline
] unit-test
{ } [
"in: classes.test.d
use: classes.test.c
use: kernel
"IN: classes.test.d
USE: classes.test.c
USE: kernel
: q ( a -- b ) dup z? [ g ] unless ;" <string-reader>
"class-intersect-no-method-d" parse-stream drop
] unit-test
! Now, the user removes the z class and adds a method,
{ } [
"in: classes.test.c
use: kernel
"IN: classes.test.c
USE: kernel
GENERIC: g ( a -- b ) ;
M: object g ;
TUPLE: j ;
@ -109,6 +108,6 @@ TUPLE: forgotten-predicate-test ;
GENERIC: generic-predicate? ( a -- b ) ;
{ } [ "in: classes.tests TUPLE: generic-predicate ;" eval( -- ) ] unit-test
{ } [ "IN: classes.tests TUPLE: generic-predicate ;" eval( -- ) ] unit-test
{ f } [ \ generic-predicate? generic? ] unit-test

View File

@ -1,7 +1,7 @@
USING: accessors classes.tuple.parser lexer words classes
sequences math kernel slots tools.test parser compiler.units
arrays classes.tuple eval multiline ;
in: classes.tuple.parser.tests
arrays classes.tuple eval ;
IN: classes.tuple.parser.tests
TUPLE: test-1 ;
@ -50,20 +50,20 @@ TUPLE: test-8 { b integer read-only } ;
defer: foo
[ "in: classes.tuple.parser.tests TUPLE: foo < test-1 < ;" eval( -- ) ]
[ "IN: classes.tuple.parser.tests TUPLE: foo < test-1 < ;" eval( -- ) ]
[ error>> invalid-slot-name? ]
must-fail-with
[ "in: classes.tuple.parser.tests TUPLE: foo :" eval( -- ) ]
[ "IN: classes.tuple.parser.tests TUPLE: foo :" eval( -- ) ]
[ error>> invalid-slot-name? ]
must-fail-with
[ "in: classes.tuple.parser.tests TUPLE: foo" eval( -- ) ]
[ "IN: classes.tuple.parser.tests TUPLE: foo" eval( -- ) ]
[ error>> unexpected-eof? ]
must-fail-with
2 [
[ "in: classes.tuple.parser.tests use: alien TUPLE: foo { slot dll } ;" eval( -- ) ]
[ "IN: classes.tuple.parser.tests use: alien TUPLE: foo { slot dll } ;" eval( -- ) ]
[ error>> bad-initial-value? ]
must-fail-with
@ -71,14 +71,14 @@ must-fail-with
] times
2 [
[ "in: classes.tuple.parser.tests use: arrays TUPLE: foo { slot array initial: 5 } ;" eval( -- ) ]
[ "IN: classes.tuple.parser.tests use: arrays TUPLE: foo { slot array initial: 5 } ;" eval( -- ) ]
[ error>> bad-initial-value? ]
must-fail-with
[ f ] [ \ foo tuple-class? ] unit-test
] times
[ "in: classes.tuple.parser.tests use: arrays TUPLE: foo slot { slot array } ;" eval( -- ) ]
[ "IN: classes.tuple.parser.tests use: arrays TUPLE: foo slot { slot array } ;" eval( -- ) ]
[ error>> duplicate-slot-names? ]
must-fail-with
@ -145,19 +145,19 @@ TUPLE: parsing-corner-case x ;
TUPLE: bad-inheritance-tuple ;
[
"in: classes.tuple.parser.tests TUPLE: bad-inheritance-tuple < bad-inheritance-tuple ;" eval( -- )
"IN: classes.tuple.parser.tests TUPLE: bad-inheritance-tuple < bad-inheritance-tuple ;" eval( -- )
] [ error>> bad-inheritance? ] must-fail-with
TUPLE: bad-inheritance-tuple2 ;
TUPLE: bad-inheritance-tuple3 < bad-inheritance-tuple2 ;
[
"in: classes.tuple.parser.tests TUPLE: bad-inheritance-tuple2 < bad-inheritance-tuple3 ;" eval( -- )
"IN: classes.tuple.parser.tests TUPLE: bad-inheritance-tuple2 < bad-inheritance-tuple3 ;" eval( -- )
] [ error>> bad-inheritance? ] must-fail-with
! This must not fail
TUPLE: tup ;
UNION: u tup ;
{ } [ "in: classes.tuple.parser.tests TUPLE: u < tup ;" eval( -- ) ] unit-test
{ } [ "IN: classes.tuple.parser.tests TUPLE: u < tup ;" eval( -- ) ] unit-test
{ t } [ u new tup? ] unit-test

View File

@ -73,8 +73,6 @@ in: modern.paths
"specialized-arrays" "specialized-vectors"
"math.blas.matrices" "math.blas.vectors" "math.vectors.simd"
"math.vectors.simd.cords" "game.debug" "gpu.util" "gpu.effects.blur"
"gpu.effects.step" "model-viewer" "terrain.shaders" "spheres"
"bunny.cel-shaded" "bunny.outlined"
} ;

View File

@ -11,7 +11,7 @@ in: game.debug
PRIVATE<
! Vertex shader for debug shapes
GLSL-SHADER: debug-shapes-vertex-shader vertex-shader
GLSL-SHADER: debug-shapes-vertex-shader vertex-shader [[
uniform mat4 u_mvp_matrix;
attribute vec3 a_position;
attribute vec3 a_color;
@ -22,15 +22,15 @@ void main()
gl_PointSize = 5.0;
v_color = a_color;
}
;
]] ;
GLSL-SHADER: debug-shapes-fragment-shader fragment-shader
GLSL-SHADER: debug-shapes-fragment-shader fragment-shader [[
varying vec3 v_color;
void main()
{
gl_FragColor = vec4(v_color, 1.0);
}
;
]] ;
VERTEX-FORMAT: debug-shapes-vertex-format
{ "a_position" float-components 3 f }
@ -43,7 +43,7 @@ GLSL-PROGRAM: debug-shapes-program debug-shapes-vertex-shader
debug-shapes-fragment-shader debug-shapes-vertex-format ;
! Vertex shader for debug text
GLSL-SHADER: debug-text-vertex-shader vertex-shader
GLSL-SHADER: debug-text-vertex-shader vertex-shader [[
attribute vec2 a_position;
attribute vec2 a_texcoord;
varying vec2 v_texcoord;
@ -52,9 +52,9 @@ void main()
gl_Position = vec4(a_position, 0.0, 1.0);
v_texcoord = a_texcoord;
}
;
]] ;
GLSL-SHADER: debug-text-fragment-shader fragment-shader
GLSL-SHADER: debug-text-fragment-shader fragment-shader [[
uniform sampler2D u_text_map;
uniform vec3 u_background_color;
varying vec2 v_texcoord;
@ -66,7 +66,7 @@ void main()
else
gl_FragColor = c;
}
;
]] ;
VERTEX-FORMAT: debug-text-vertex-format
{ "a_position" float-components 2 f }
@ -86,13 +86,13 @@ CONSTANT: debug-text-font
{ bold? f }
{ italic? f }
{ foreground color: white }
{ background color: black } }
{ background color: black } } ;
CONSTANT: debug-text-texture-parameters
T{ texture-parameters
{ wrap repeat-texcoord }
{ min-filter filter-linear }
{ min-mipmap-filter f } }
{ min-mipmap-filter f } } ;
: text>image ( string color -- image )
debug-text-font clone swap >>foreground swap string>image drop ;
@ -159,10 +159,10 @@ CONSTANT: box-vertices
{ { -1 1 -1 } { -1 1 1 } }
{ { -1 1 -1 } { 1 1 -1 } }
{ { 1 -1 -1 } { 1 -1 1 } }
{ { 1 -1 -1 } { 1 1 -1 } } }
{ { 1 -1 -1 } { 1 1 -1 } } } ;
CONSTANT: cylinder-vertices
$[ 12 iota [ 2pi 12 / * [ cos ] [ drop 0.0 ] [ sin ] tri 3array ] map ]
$[ 12 iota [ 2pi 12 / * [ cos ] [ drop 0.0 ] [ sin ] tri 3array ] map ] ;
:: scale-cylinder-vertices ( radius half-height verts -- bot-verts top-verts )
verts

View File

@ -5,7 +5,7 @@ gpu.state gpu.textures gpu.util images kernel locals math
math.rectangles sequences ;
in: gpu.effects.blur
GLSL-SHADER: blur-fragment-shader fragment-shader
GLSL-SHADER: blur-fragment-shader fragment-shader [[
uniform sampler2D texture;
uniform bool horizontal;
uniform float blurSize;
@ -45,7 +45,7 @@ void main()
}
gl_FragColor = col;
}
;
]] ;
UNIFORM-TUPLE: blur-uniforms
{ "texture" texture-uniform f }

View File

@ -4,7 +4,7 @@ USING: destructors gpu.render gpu.shaders gpu.state gpu.textures
gpu.util images kernel locals math.rectangles ;
in: gpu.effects.step
GLSL-SHADER: step-fragment-shader fragment-shader
GLSL-SHADER: step-fragment-shader fragment-shader [[
const vec4 luminance = vec4(0.3, 0.59, 0.11, 0.0);
uniform sampler2D texture;
uniform sampler2D ramp;
@ -15,7 +15,7 @@ void main()
float l = dot(col, luminance);
gl_FragColor = texture2D(ramp, vec2(l, 0.0));
}
;
]] ;
UNIFORM-TUPLE: step-uniforms
{ "texture" texture-uniform f }

View File

@ -39,11 +39,11 @@ HELP: \ GLSL-SHADER-FILE:
{ $description "Defines a new " { $link shader } " of kind " { $link shader-kind } " named " { $snippet "shader-name" } ". The shader will read its source code from " { $snippet "filename" } " in the current Factor source file's directory." } ;
HELP: \ GLSL-SHADER:
{ $syntax "GLSL-SHADER: shader-name shader-kind
{ $syntax "GLSL-SHADER: shader-name shader-kind [[
shader source
;" }
]] ;" }
{ $description "Defines a new " { $link shader } " of kind " { $link shader-kind } " named " { $snippet "shader-name" } ". The shader will read its source code from the current Factor source file between the " { $snippet "GLSL-SHADER:" } " line and the first subsequent line with a single semicolon on it." } ;
HELP: \ VERTEX-FORMAT:

View File

@ -591,7 +591,7 @@ SYNTAX: \ GLSL-SHADER:
scan-word
f
lexer get line>>
parse-here
scan-object
] dip
shader boa
over reset-generic

View File

@ -46,7 +46,7 @@ CONSTANT: environment-cube-map-mv-matrices
} }
} ;
GLSL-SHADER: window-vertex-shader vertex-shader
GLSL-SHADER: window-vertex-shader vertex-shader [[
attribute vec2 vertex;
varying vec2 texcoord;
void main()
@ -54,16 +54,16 @@ void main()
texcoord = vertex * vec2(0.5) + vec2(0.5);
gl_Position = vec4(vertex, 0.0, 1.0);
}
;
]] ;
GLSL-SHADER: window-fragment-shader fragment-shader
GLSL-SHADER: window-fragment-shader fragment-shader [[
uniform sampler2D texture;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(texture, texcoord);
}
;
]] ;
VERTEX-FORMAT: window-vertex-format
{ "vertex" float-components 2 f } ;
@ -73,7 +73,7 @@ UNIFORM-TUPLE: window-uniforms
GLSL-PROGRAM: window-program window-vertex-shader window-fragment-shader window-vertex-format ;
GLSL-SHADER: window-point-vertex-shader vertex-shader
GLSL-SHADER: window-point-vertex-shader vertex-shader [[
uniform float point_size;
attribute vec2 vertex;
void main()
@ -81,16 +81,16 @@ void main()
gl_Position = vec4(vertex, 0.0, 1.0);
gl_PointSize = point_size;
}
;
]] ;
GLSL-SHADER: window-point-fragment-shader fragment-shader
GLSL-SHADER: window-point-fragment-shader fragment-shader [[
#version 120
uniform sampler2D texture;
void main()
{
gl_FragColor = texture2D(texture, gl_PointCoord);
}
;
]] ;
UNIFORM-TUPLE: window-point-uniforms
{ "texture" texture-uniform f }

View File

@ -16,7 +16,7 @@ specialized-array: float
specialized-vector: uint
in: model-viewer
GLSL-SHADER: obj-vertex-shader vertex-shader
GLSL-SHADER: obj-vertex-shader vertex-shader [[
uniform mat4 mv_matrix;
uniform mat4 p_matrix;
@ -36,9 +36,9 @@ void main()
texcoord_fs = TEXCOORD;
normal_fs = NORMAL;
}
;
]] ;
GLSL-SHADER: obj-fragment-shader fragment-shader
GLSL-SHADER: obj-fragment-shader fragment-shader [[
uniform mat4 mv_matrix, p_matrix;
uniform sampler2D map_Ka;
uniform sampler2D map_bump;
@ -60,7 +60,7 @@ void main()
gl_FragColor = d * cosTh
+ d * 0.5 * cosTh * pow(saturate(dot(n, h)), 10.0) ;
}
;
]] ;
GLSL-PROGRAM: obj-program
obj-vertex-shader obj-fragment-shader ;