Skip to content

What shapes do

Calico Niko edited this page Dec 1, 2022 · 11 revisions

Memory

Shapes is stack-based. Some shapes could pop and push from and to the Global Stack.

The Global Stack is the stack that is used by most shapes. The term "Global Stack" is used to avoid confusion with Local Stacks (colloquially known as mini stacks). Local Stacks are extra stacks you could use with the STACK shape.

All shapes have values but only some shapes could have values other than None.

Data

There are only two data types in Shapes. Strings and numbers. Chars are strings with only one character. Booleans are represented with numbers either 0 or 1.

Reference

Here are all the shapes and what they do. First is the first thing that is popped from the stack. I don't think I need to tell you what second means.

NSN Name What
1 yes : 3 yes START Instruction pointer starts here.
7 np : no IN Pushes input that is collected with <<< and converts it to a number if possible.
6 yes : no OUT Pops and prints first.
6 yes : 1 OUT_NO_LF Pops and prints first without a new line.
7 no : 1 idk READ Pops and reads file at first. See Read.
5 no : no CONTAINER Temporarily stores data. See Container.
5 no : yes STACK For when you need more stacks. See Stack.
4 yes : no JUNCTION Does nothing. Good for crossing paths.
5 yes : idk NUMBER Pushes the amount of holes it has.
6 no : no POP Pops first and does nothing with it. Basically deletes it.
3 yes : 3 DUPE Pushes first without popping it thereby duplicating it.
4 yes : 5 yes NUMBER_CHECK Pops first and pushes whether first is a number or not.
4 no : no TO_STRING Pops first and pushes first that has been converted into a string.
4 no : 2 TO_CHAR Pops first and pushes first that has been converted to char(s). See To Char.
4 no : 3 CHR_TO_NUM Pops first and pushes the Unicode code point of first if first is a char.
4 no : 1 TO_NUMBER Pops first and pushes first that has been tried to convert into a number.
6 no : yes OPER Does a different operation depending on how many holes it has. See Operations.
8 no : 1 idk OR Pops first and second. Pushes first or second.
8 no : 4 idk AND Pops first and second. Pushes first and second.
8 no : 3 idk NOT Pops first and pushes not first.
8 no : 2 SMALLER Pops first and second. Pushes first < second.
8 no : 3 EQUALS Pops first and second. Pushes first == second.
8 no : 4 LARGER Pops first and second. Pushes first > second.
2 no : no LENGTH Pushes the length of stack.
3 yes : no CONTROL For controlling the flow. See Control.
1 yes : 4 yes END Ends program.

Read

Reads file at first as text file. Pushes 0 if file is not found. Pushes 1 if it's not possible to read file as text file.

Container

If value of container is None, pop first and set value to first. If value of container is not None, push value and set container value to None.

Stack

This shape has a stack. The value of this shape is the top of its stack.

If size of stack is more than one, pop first, pop second, and:

If first is Then
0 Push second to global stack. Pop top of local stack and push it to global stack.
1 Push second to local stack.
2 Push second to global stack. Push size of local stack to global stack.
anything else Push second and push first to global stack.

To Char

If first is a number, push the string representing a character whose Unicode code point is first that has been converted into an integer.

If first is a string, push each character of the string from the last character to the first character.

Operations

The OPER shape does different things depending on how much holes it has.

Number of holes Do
1 Push first+second.
2 Push first-second.
3 Push first*second.
4 Push first/second.
5 Push first%second.
6 Convert first and second to strings and push first+second.
>6 Push first and push second, thereby swapping first and second.

Operation shapes like OPER, the comparison shapes, and the logic shapes might push back first and second to the global stack if it's not possible to do the operation on them.

For example, let's say the stack is ["1", 1] and the instruction pointer goes to an OPER shape that subtracts. Nothing happens here because it isn't possible to subtract "1" from 1.

Control

Instead of moving the instruction pointer like usual, pop first and move the instruction pointer to the nearest shape with value of first. If there is none, move the instruction pointer to the nearest shape with no value