Skip to content

Commit

Permalink
Move <memory> to file
Browse files Browse the repository at this point in the history
Move default memory size to <bf>
  • Loading branch information
fraya committed May 13, 2024
1 parent cb68f6d commit 46c8fc0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
15 changes: 2 additions & 13 deletions sources/brainfuck.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,15 @@ Synopsis: Brainfuck core
Author: Fernando Raya
Copyright: GPLv3

define constant $memory-size
= 30000;

define constant <memory-cell>
= <integer>;

define constant <memory>
= limited(<vector>, of: <memory-cell>, size: $memory-size);

define constant <memory-pointer>
= <integer>;

define sealed class <bf> (<object>)
slot bf-pp :: <program-pointer> = 0,
init-keyword: program-pointer:;
slot bf-mp :: <memory-pointer> = 0,
init-keyword: memory-pointer:;
constant slot bf-program :: <program>,
required-init-keyword: program:;
constant slot bf-memory :: <memory> = make(<memory>, fill: 0),
constant slot bf-memory :: <memory>
= make(<memory>, fill: 0, size: $default-memory-size),
init-keyword: memory:;
end;

Expand Down
1 change: 1 addition & 0 deletions sources/brainfuck.lid
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Library: brainfuck
Files: library.dylan
memory.dylan
instruction.dylan
comment-instruction.dylan
io-instruction.dylan
Expand Down
16 changes: 16 additions & 0 deletions sources/memory.dylan
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Module: brainfuck-impl
Synopsis: Brainfuck memory
Author: Fernando Raya
Copyright: GPLv3

define constant $default-memory-size
= 30000;

define constant <memory-cell>
= <integer>;

define constant <memory>
= limited(<vector>, of: <memory-cell>);

define constant <memory-pointer>
= <integer>;

0 comments on commit 46c8fc0

Please sign in to comment.