factor: STRING: foo ; to CONSTANT: foo [[ ]]

modern-harvey2
Doug Coleman 2017-08-26 15:48:56 -05:00
parent 2114b7efc5
commit 15a7484b6f
24 changed files with 118 additions and 118 deletions

View File

@ -5,7 +5,7 @@ strings ;
IN: compiler.cfg.builder.alien
<<
STRING: ex-caller-return
CONSTANT: ex-caller-return [[
USING: compiler.cfg.builder.alien make prettyprint ;
[
T{ ##alien-invoke { reg-outputs { { 1 int-rep RAX } } } } ,
@ -15,7 +15,7 @@ USING: compiler.cfg.builder.alien make prettyprint ;
T{ ##alien-invoke { reg-outputs { { 1 int-rep RAX } } } }
T{ ##box-alien { dst 116 } { src 1 } { temp 115 } }
}
;
]]
>>
HELP: caller-linkage

View File

@ -3,7 +3,7 @@ help.syntax literals make math multiline quotations sequences ;
IN: compiler.cfg.builder.blocks
<<
STRING: ex-emit-trivial-block
CONSTANT: ex-emit-trivial-block [[
USING: compiler.cfg.builder.blocks make prettyprint ;
begin-stack-analysis <basic-block> dup set-basic-block [ gensym ##call, drop ] emit-trivial-block predecessors>> first .
T{ basic-block
@ -24,7 +24,7 @@ T{ basic-block
}
}
}
;
]]
>>
HELP: begin-basic-block

View File

@ -5,7 +5,7 @@ sequences vectors words ;
IN: compiler.cfg.builder
<<
STRING: ex-emit-call
CONSTANT: ex-emit-call [[
USING: compiler.cfg.builder compiler.cfg.builder.blocks compiler.cfg.stacks
kernel make prettyprint ;
begin-stack-analysis <basic-block> set-basic-block
@ -32,13 +32,13 @@ T{ basic-block
}
}
}
;
]]
STRING: ex-make-input-map
CONSTANT: ex-make-input-map [[
USING: compiler.cfg.builder prettyprint ;
T{ #shuffle { in-d { 37 81 92 } } } make-input-map .
{ { 37 d: 2 } { 81 d: 1 } { 92 d: 0 } }
;
]]
>>
HELP: build-cfg

View File

@ -2,12 +2,12 @@ USING: help.markup help.syntax literals multiline sequences splitting ;
IN: compiler.cfg.instructions.syntax
<<
STRING: parse-insn-slot-specs-code
CONSTANT: parse-insn-slot-specs-code [[
USING: compiler.cfg.instructions.syntax prettyprint splitting ;
"use: src/int-rep temp: temp/int-rep" " " split parse-insn-slot-specs .
;
]]
STRING: parse-insn-slot-specs-result
CONSTANT: parse-insn-slot-specs-result [[
{
T{ insn-slot-spec
{ type use }
@ -20,7 +20,7 @@ STRING: parse-insn-slot-specs-result
{ rep int-rep }
}
}
;
]]
>>
HELP: parse-insn-slot-specs

View File

@ -5,12 +5,12 @@ sequences ;
IN: compiler.codegen
<<
STRING: generate-ex
CONSTANT: generate-ex [[
USING: compiler.cfg.debugger io prettyprint ;
[ "hello\n" write ] test-regs first dup cfg set generate [ . ] [ 4 swap nth disassemble ] bi
;
]]
STRING: generate-ex-answer
CONSTANT: generate-ex-answer [[
{
{ }
{ "hello\n" output-stream assoc-stack stream-write }
@ -51,7 +51,7 @@ STRING: generate-ex-answer
0000000001cc4cfa: 0000 add [rax], al
0000000001cc4cfc: 0000 add [rax], al
0000000001cc4cfe: 0000 add [rax], al
;
]]
>>
HELP: emit-branch

View File

@ -2,7 +2,7 @@ USING: help.markup help.syntax literals multiline ;
IN: compiler.tree.propagation
<<
STRING: propagate-ex
CONSTANT: propagate-ex [[
USING: compiler.tree.builder compiler.tree.propagation math prettyprint ;
[ 3 + ] build-tree propagate third .
T{ #call
@ -42,7 +42,7 @@ T{ #call
}
}
}
;
]]
>>
HELP: propagate

View File

@ -5,7 +5,7 @@ literals math multiline sequences strings system vm words ;
IN: cpu.architecture
<<
STRING: ex-%allot
CONSTANT: ex-%allot [[
USING: cpu.architecture make ;
[ RAX 40 tuple RCX %allot ] B{ } make disassemble
0000000002270cc0: 498d4d10 lea rcx, [r13+0x10]
@ -13,9 +13,9 @@ USING: cpu.architecture make ;
0000000002270cc7: 48c7001c000000 mov qword [rax], 0x1c
0000000002270cce: 4883c807 or rax, 0x7
0000000002270cd2: 48830130 add qword [rcx], 0x30
;
]]
STRING: ex-%box-alien
CONSTANT: ex-%box-alien [[
USING: compiler.codegen compiler.codegen.relocation cpu.architecture make ;
[ RAX RBX RCX %box-alien ] with-fixup 4 swap nth disassemble
000000e9fcc720a0: 48b80100000000000000 mov eax, 0x1
@ -30,27 +30,27 @@ USING: compiler.codegen compiler.codegen.relocation cpu.architecture make ;
000000e9fcc720d1: 48c7400a01000000 mov qword [rax+0xa], 0x1
000000e9fcc720d9: 48895812 mov [rax+0x12], rbx
000000e9fcc720dd: 4889581a mov [rax+0x1a], rbx
;
]]
STRING: ex-%context
CONSTANT: ex-%context [[
USING: cpu.architecture make ;
[ EAX %context ] B{ } make disassemble
00000000010f5ed0: 418b4500 mov eax, [r13]
;
]]
STRING: ex-%copy
CONSTANT: ex-%copy [[
USING: cpu.architecture make ;
RAX RBX int-rep [ %copy ] B{ } make disassemble
000000000108a970: 4889d8 mov rax, rbx
;
]]
STRING: ex-%safepoint
CONSTANT: ex-%safepoint [[
USING: cpu.architecture make ;
init-relocation [ %safepoint ] B{ } make disassemble
00000000010b05a0: 890500000000 mov [rip], eax
;
]]
STRING: ex-%save-context
CONSTANT: ex-%save-context [[
USING: cpu.architecture make ;
[ RAX RBX %save-context ] B{ } make disassemble
0000000000e63ab0: 498b4500 mov rax, [r13]
@ -58,9 +58,9 @@ USING: cpu.architecture make ;
0000000000e63ab9: 488918 mov [rax], rbx
0000000000e63abc: 4c897010 mov [rax+0x10], r14
0000000000e63ac0: 4c897818 mov [rax+0x18], r15
;
]]
STRING: ex-%write-barrier
CONSTANT: ex-%write-barrier [[
USING: cpu.architecture make tools.disassembler ;
init-relocation [ RAX RBX 3 -14 RCX RDX %write-barrier ] B{ } make disassemble
000000000143f960: 488d4cd80e lea rcx, [rax+rbx*8+0xe]
@ -70,7 +70,7 @@ init-relocation [ RAX RBX 3 -14 RCX RDX %write-barrier ] B{ } make disassemble
000000000143f978: 48c1e90a shr rcx, 0xa
000000000143f97c: 48ba0000000000000000 mov rdx, 0x0
000000000143f986: 48c60411c0 mov byte [rcx+rdx], 0xc0
;
]]
>>
HELP: %alien-invoke

View File

@ -7,11 +7,11 @@ IN: furnace.actions.tests
[ "a" param "b" param [ string>number ] bi@ + ] >>display
"action-1" set
STRING: action-request-test-1
CONSTANT: action-request-test-1 [[
GET http://foo/bar?a=12&b=13 HTTP/1.1
blah
;
]]
{ 25 } [
action-request-test-1 lf>crlf
@ -25,11 +25,11 @@ blah
[ "a" param string>number sq ] >>display
"action-2" set
STRING: action-request-test-2
CONSTANT: action-request-test-2 [[
GET http://foo/bar/123 HTTP/1.1
blah
;
]]
{ 25 } [
action-request-test-2 lf>crlf

View File

@ -3,11 +3,11 @@ multiline parser tools.test webapps.counter ;
IN: furnace.utilities.tests
<<
STRING: dummy-vocab
CONSTANT: dummy-vocab [[
IN: dummy-vocab
: dummy-word ( -- ) ;
;
]]
dummy-vocab "dummy.factor" temp-file [ utf8 set-file-contents ] keep run-file
>>

View File

@ -25,7 +25,7 @@ IN: http.tests
{ "localhost:8080" } [ T{ url { protocol "http" } { host "localhost" } { port 8080 } } unparse-host ] unit-test
{ "localhost:8443" } [ T{ url { protocol "https" } { host "localhost" } { port 8443 } } unparse-host ] unit-test
STRING: read-request-test-1
CONSTANT: read-request-test-1 [[
POST /bar HTTP/1.1
Some-Header: 1
Some-Header: 2
@ -33,7 +33,7 @@ Content-Length: 4
Content-type: application/octet-stream
blah
;
]]
{
T{ request
@ -52,14 +52,14 @@ blah
] with-string-reader
] unit-test
STRING: read-request-test-1'
CONSTANT: read-request-test-1' [[
POST /bar HTTP/1.1
content-length: 4
content-type: application/octet-stream
some-header: 1; 2
blah
;
]]
${ read-request-test-1' } [
read-request-test-1 lf>crlf
@ -69,11 +69,11 @@ ${ read-request-test-1' } [
string-lines "\n" join
] unit-test
STRING: read-request-test-2
CONSTANT: read-request-test-2 [[
HEAD /bar HTTP/1.1
Host: www.sex.com
;
]]
{
T{ request
@ -91,11 +91,11 @@ Host: www.sex.com
] with-string-reader
] unit-test
STRING: read-request-test-2'
CONSTANT: read-request-test-2' [[
HEAD /bar HTTP/1.1
Host: www.sex.com:101
;
]]
{
T{ request
@ -113,15 +113,15 @@ Host: www.sex.com:101
] with-string-reader
] unit-test
STRING: read-request-test-3
CONSTANT: read-request-test-3 [[
GET nested HTTP/1.0
;
]]
STRING: read-request-test-4
CONSTANT: read-request-test-4 [[
GET /blah HTTP/1.0
Host: "www.amazon.com"
;
]]
{ "www.amazon.com" }
[
@ -129,12 +129,12 @@ Host: "www.amazon.com"
"host" header
] unit-test
STRING: read-response-test-1
CONSTANT: read-response-test-1 [[
HTTP/1.1 404 not found
Content-Type: text/html; charset=UTF-8
blah
;
]]
{
T{ response
@ -153,11 +153,11 @@ blah
] unit-test
STRING: read-response-test-1'
CONSTANT: read-response-test-1' [[
HTTP/1.1 404 not found
content-type: text/html; charset=UTF-8
;
]]
${ read-response-test-1' } [
URL" http://localhost/" url set
@ -178,12 +178,12 @@ ${ read-response-test-1' } [
dup parse-set-cookie first unparse-set-cookie =
] unit-test
STRING: read-response-test-2
CONSTANT: read-response-test-2 [[
HTTP/1.1 200 Content follows
Set-Cookie: oo="bar; a=b"; httponly=yes; sid=123456
;
]]
{ 2 } [
read-response-test-2 lf>crlf
@ -191,12 +191,12 @@ Set-Cookie: oo="bar; a=b"; httponly=yes; sid=123456
cookies>> length
] unit-test
STRING: read-response-test-3
CONSTANT: read-response-test-3 [[
HTTP/1.1 200 Content follows
Set-Cookie: oo="bar; a=b"; comment="your mom"; httponly=yes
;
]]
{ 1 } [
read-response-test-3 lf>crlf

View File

@ -34,7 +34,7 @@ IN: http.server.requests.tests
] unit-test
! multipart/form-data
STRING: test-multipart/form-data
CONSTANT: test-multipart/form-data [[
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
@ -50,7 +50,7 @@ Content-Disposition: form-data; name="text"; filename="upload.txt"
hello
--768de80194d942619886d23f1337aa15--
;
]]
{
"upload.txt"
H{
@ -65,7 +65,7 @@ hello
! Error handling
! If the incoming request is not valid, read-request should throw an
! appropriate error.
STRING: test-multipart/form-data-missing-boundary
CONSTANT: test-multipart/form-data-missing-boundary [[
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
@ -81,7 +81,7 @@ Content-Disposition: form-data; name="text"; filename="upload.txt"
hello
--768de80194d942619886d23f1337aa15--
;
]]
[ test-multipart/form-data-missing-boundary string>request ]
[ no-boundary? ] must-fail-with

View File

@ -1,11 +1,11 @@
USING: eval multiline sequences tools.test ;
IN: multiline.tests
STRING: test-it
CONSTANT: test-it [[
foo
bar
;
]]
{ "foo\nbar\n" } [ test-it ] unit-test
@ -71,7 +71,7 @@ lol
xyz
] unit-test
/*
![[
<<
SYNTAX: \MULTILINE-LITERAL: parse-here suffix! ;
>>
@ -91,4 +91,4 @@ bar
;
}" eval
] must-fail
*/
]]

View File

@ -20,16 +20,16 @@ M: object (r-ref) drop ;
! Example
STRING: sample-doc
CONSTANT: sample-doc [[
<html xmlns:f='http://littledan.onigirihouse.com/namespaces/replace'>
<body>
<span f:sub='foo'/>
<div f:sub='bar'/>
<p f:sub='baz'>paragraph</p>
</body></html>
;
]]
STRING: expected-result
CONSTANT: expected-result [[
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:f="http://littledan.onigirihouse.com/namespaces/replace">
<body>
@ -43,7 +43,7 @@ STRING: expected-result
<p f:sub="baz"/>
</body>
</html>
;
]]
: test-refs ( -- string )
[

View File

@ -3,7 +3,7 @@ multiline opengl opengl.shaders opengl.capabilities opengl.gl
sequences accessors combinators ;
IN: bunny.cel-shaded
STRING: vertex-shader-source
CONSTANT: vertex-shader-source [[
varying vec3 position, normal, viewer;
void
@ -16,9 +16,9 @@ main()
viewer = vec3(0, 0, 1) * gl_NormalMatrix;
}
;
]]
STRING: cel-shaded-fragment-shader-lib-source
CONSTANT: cel-shaded-fragment-shader-lib-source [[
varying vec3 position, normal, viewer;
uniform vec3 light_direction;
uniform vec4 color;
@ -47,9 +47,9 @@ cel_light()
return ad * color + vec4(vec3(s), 0);
}
;
]]
STRING: cel-shaded-fragment-shader-main-source
CONSTANT: cel-shaded-fragment-shader-main-source [[
vec4 cel_light();
void
@ -58,7 +58,7 @@ main()
gl_FragColor = cel_light();
}
;
]]
TUPLE: bunny-cel-shaded program ;

View File

@ -6,7 +6,7 @@ macros locals ;
FROM: opengl.demo-support => rect-vertices ;
IN: bunny.outlined
STRING: outlined-pass1-fragment-shader-main-source
CONSTANT: outlined-pass1-fragment-shader-main-source [[
varying vec3 normal;
vec4 cel_light();
@ -17,9 +17,9 @@ main()
gl_FragData[1] = vec4(normal, 1);
}
;
]]
STRING: outlined-pass2-vertex-shader-source
CONSTANT: outlined-pass2-vertex-shader-source [[
varying vec2 coord;
void
@ -29,9 +29,9 @@ main()
coord = (gl_Vertex * vec4(0.5) + vec4(0.5)).xy;
}
;
]]
STRING: outlined-pass2-fragment-shader-source
CONSTANT: outlined-pass2-fragment-shader-source [[
uniform sampler2D colormap, normalmap, depthmap;
uniform vec4 line_color;
varying vec2 coord;
@ -111,7 +111,7 @@ main()
gl_FragColor = mix(texture2D(colormap, coord), line_color, border_factor(coord));
}
;
]]
TUPLE: bunny-outlined
gadget

View File

@ -4,7 +4,7 @@ USING: elf.nm io io.streams.string kernel literals multiline strings
system tools.test ;
IN: elf.nm.tests
STRING: validation-output
CONSTANT: validation-output [[
0000000000000000 absolute init.c
000000000040046c .text call_gmon_start
0000000000000000 absolute crtstuff.c
@ -44,7 +44,7 @@ STRING: validation-output
0000000000400524 .text main
00000000004003f0 .init _init
;
]]
cpu ppc? [
{ $ validation-output }

View File

@ -4,7 +4,7 @@ USING: accessors alien io io.streams.string kernel literals macho
multiline sequences strings system tools.test ;
IN: macho.tests
STRING: validation-output
CONSTANT: validation-output [[
0000000100000f1c __stub_helper stub helpers
0000000100001040 __program_vars _pvars
0000000100001068 __data _NXArgc
@ -19,7 +19,7 @@ STRING: validation-output
0000000000000000 _printf
0000000000000000 dyld_stub_binder
;
]]
cpu ppc? [
{ $ validation-output }

View File

@ -7,7 +7,7 @@ FROM: alien.c-types => float ;
SPECIALIZED-ARRAYS: float void* ;
IN: opencl.ffi.tests
STRING: kernel-source
CONSTANT: kernel-source [[
__kernel void square(
__global float* input,
__global float* output,
@ -17,7 +17,7 @@ __kernel void square(
if (i < count)
output[i] = input[i] * input[i];
}
;
]]
ERROR: cl-error err ;
: cl-success ( err -- )

View File

@ -7,7 +7,7 @@ FROM: alien.c-types => float ;
SPECIALIZED-ARRAY: float
IN: opencl.tests
STRING: kernel-source
CONSTANT: kernel-source [[
__kernel void square(
__global float* input,
__global float* output,
@ -17,7 +17,7 @@ __kernel void square(
if (i < count)
output[i] = input[i] * input[i];
}
;
]]
:: opencl-square ( in -- out )
[

View File

@ -34,7 +34,7 @@ SYNTAX: \copy-slots{
] map-tokens
'[ swap _ cleave ] append! ;
SYNTAX: \get[ postpone: slots[ ;
SYNTAX: \get{ postpone: slots{ ;
SYNTAX: \set[ postpone: set-slots[ ;
SYNTAX: \set{ postpone: set-slots{ ;
SYNTAX: \get[ postpone: \slots[ ;
SYNTAX: \get{ postpone: \slots{ ;
SYNTAX: \set[ postpone: \set-slots[ ;
SYNTAX: \set{ postpone: \set-slots{ ;

View File

@ -5,7 +5,7 @@ generalizations combinators ui.gadgets.worlds
literals ui.pixel-formats ;
IN: spheres
STRING: plane-vertex-shader
CONSTANT: plane-vertex-shader [[
varying vec3 object_position;
void
main()
@ -13,9 +13,9 @@ main()
object_position = gl_Vertex.xyz;
gl_Position = ftransform();
}
;
]]
STRING: plane-fragment-shader
CONSTANT: plane-fragment-shader [[
uniform float checker_size_inv;
uniform vec4 checker_color_1, checker_color_2;
varying vec3 object_position;
@ -37,9 +37,9 @@ main()
? mix(checker_color_1, checker_color_2, distance_factor)
: mix(checker_color_2, checker_color_1, distance_factor);
}
;
]]
STRING: sphere-vertex-shader
CONSTANT: sphere-vertex-shader [[
attribute vec3 center;
attribute float radius;
attribute vec4 surface_color;
@ -58,9 +58,9 @@ main()
vcolor = surface_color;
vradius = radius;
}
;
]]
STRING: sphere-solid-color-fragment-shader
CONSTANT: sphere-solid-color-fragment-shader [[
uniform vec3 light_position;
varying vec4 vcolor;
@ -76,9 +76,9 @@ sphere_color(vec3 point, vec3 normal)
return ambient * vcolor + diffuse * vec4(d * vcolor.rgb, vcolor.a);
}
;
]]
STRING: sphere-texture-fragment-shader
CONSTANT: sphere-texture-fragment-shader [[
uniform samplerCube surface_texture;
vec4
@ -87,9 +87,9 @@ sphere_color(vec3 point, vec3 normal)
vec3 reflect = reflect(normalize(point), normal);
return textureCube(surface_texture, reflect * gl_NormalMatrix);
}
;
]]
STRING: sphere-main-fragment-shader
CONSTANT: sphere-main-fragment-shader [[
varying float vradius;
varying vec3 sphere_position;
varying vec4 world_position;
@ -109,7 +109,7 @@ main()
gl_FragDepth = (transformed_surface.z/transformed_surface.w + 1.0) * 0.5;
gl_FragColor = sphere_color(world_surface.xyz, surface);
}
;
]]
TUPLE: spheres-world < demo-world
plane-program solid-sphere-program texture-sphere-program

View File

@ -103,11 +103,11 @@ ${
" svg-path>array
] unit-test
STRING: test-svg-string
CONSTANT: test-svg-string [[
<svg xmlns="http://www.w3.org/2000/svg">
<path transform="translate(1 2)" d="M -1 -1 l 2 2" />
</svg>
;
]]
: test-svg-path ( -- obj )
test-svg-string string>xml body>> children-tags first ;

View File

@ -1,7 +1,7 @@
USING: multiline ;
IN: terrain.shaders
STRING: sky-vertex-shader
CONSTANT: sky-vertex-shader [[
uniform float sky_theta;
varying vec3 direction;
@ -19,9 +19,9 @@ void main()
* (gl_ModelViewMatrixInverse * vec4(p.xyz, 0.0)).xyz;
}
;
]]
STRING: sky-pixel-shader
CONSTANT: sky-pixel-shader [[
uniform sampler2D sky;
uniform float sky_gradient, sky_theta;
@ -37,9 +37,9 @@ void main()
gl_FragColor = mix(SKY_COLOR_A, SKY_COLOR_B, sin(6.28*t));
}
;
]]
STRING: terrain-vertex-shader
CONSTANT: terrain-vertex-shader [[
uniform sampler2D heightmap;
uniform vec4 component_scale;
@ -59,9 +59,9 @@ void main()
heightcoords = gl_Vertex.xz;
}
;
]]
STRING: terrain-pixel-shader
CONSTANT: terrain-pixel-shader [[
uniform sampler2D heightmap;
uniform vec4 component_scale;
@ -79,4 +79,4 @@ void main()
gl_FragColor = texture2D(heightmap, heightcoords);
}
;
]]

View File

@ -177,7 +177,7 @@ TUPLE: text-analysis #paragraphs #sentences #chars #words
]
[ words-per-sentence 0.0496 * ] bi + ;
STRING: text-report-format
CONSTANT: text-report-format [[
Number of paragraphs %d
Number of sentences %d
Number of words %d
@ -194,7 +194,7 @@ SMOG grade %2.2f
Automated Readability index %2.2f
Dale-Chall readability %2.2f
;
]]
PRIVATE>