Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 tile-lang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 2 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Explicitly list subdirs since wildcard */ is failing
EXAMPLE_DIRS := snake/ string/ forloop/
TILE_FILES := $(wildcard snake/*.tile string/*.tile forloop/*.tile)
TILE_FILES := $(wildcard snake/*.tile pong/*.tile forloop/*.tile tic-tac-toe/*.tile)
TASM_FILES := $(TILE_FILES:.tile=.tasm)
BIN_FILES := $(TASM_FILES:.tasm=.bin)

Expand All @@ -14,7 +14,7 @@ $(info TILE_FILES: $(TILE_FILES))
$(info TASM_FILES: $(TASM_FILES))
$(info BIN_FILES: $(BIN_FILES))
$(info WILDCARD DIRS: $(wildcard */))
$(info WILDCARD TILES: $(wildcard snake/*.tile string/*.tile forloop/*.tile))
$(info WILDCARD TILES: $(wildcard snake/*.tile pong/*.tile forloop/*.tile tic-tac-toe/*.tile))

all: $(BIN_FILES)
@echo "Done building: $(BIN_FILES)"
Expand Down
18 changes: 2 additions & 16 deletions examples/snake/snake.tile
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
/*
01.14.2025
04.26.2025
Muhammed Yasinhan Yaşar
*/

native func InitWindow(width: ci32, height: ci32, title: cptr): cvoid;
native func WindowShouldClose(): ci8;
native func CloseWindow(): cvoid;
native func BeginDrawing(): cvoid;
native func EndDrawing(): cvoid;
native func ClearBackground(color: cu32): cvoid;
native func SetTargetFPS(fps: ci32): cvoid;
native func GetFrameTime(): cf32;
native func DrawRectangle(posX: ci32, posY: ci32, width: ci32, height: ci32, color: cu32): cvoid;
native func DrawCircle(posX: ci32, posY: ci32, radius: cf32, color: cu32): cvoid;
native func DrawLine(ci32, ci32, ci32, ci32, cu32): cvoid;
native func IsKeyDown(key: ci16): ci8;

native func SetRandomSeed(seed: cu32): cvoid;
native func GetRandomValue(min: ci32, max: ci32): ci32;
import "../tileraylib.tile";

screenWidth: int = 400;
screenHeight: int = screenWidth;
Expand Down
20 changes: 20 additions & 0 deletions examples/tileraylib.tile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
04.26.2025
Muhammed Yasinhan Yaşar
*/

native func InitWindow(width: ci32, height: ci32, title: cptr): cvoid;
native func WindowShouldClose(): ci8;
native func CloseWindow(): cvoid;
native func BeginDrawing(): cvoid;
native func EndDrawing(): cvoid;
native func ClearBackground(color: cu32): cvoid;
native func SetTargetFPS(fps: ci32): cvoid;
native func GetFrameTime(): cf32;
native func DrawRectangle(posX: ci32, posY: ci32, width: ci32, height: ci32, color: cu32): cvoid;
native func DrawCircle(posX: ci32, posY: ci32, radius: cf32, color: cu32): cvoid;
native func DrawLine(ci32, ci32, ci32, ci32, cu32): cvoid;
native func IsKeyDown(key: ci16): ci8;

native func SetRandomSeed(seed: cu32): cvoid;
native func GetRandomValue(min: ci32, max: ci32): ci32;
21 changes: 9 additions & 12 deletions src/tile/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class Program extends Generator {
public static List<BlockStmt> blockStack = new ArrayList<>();
private static int tasmGlobalVarIdx = 0;
public static Map<String, Variable> globalVariableSymbols = new HashMap<>();
public static List<Statement> globalVariables = new ArrayList<Statement>();
public static Deque<Statement> parentStack = new ArrayDeque<>();
public static List<Path> programPaths = new ArrayList<>();
private static boolean _err;
Expand Down Expand Up @@ -65,8 +66,6 @@ public void addStatement(Statement stmt) {
}

private String generateProgram(String generatedCode) {
List<Statement> globalVariables = new ArrayList<Statement>();

if (!isImportedFile) {
generatedCode += "; program begins\n";
generatedCode += "jmp __start\n";
Expand All @@ -85,17 +84,15 @@ private String generateProgram(String generatedCode) {
}

if(!isImportedFile) {
generatedCode += "__start:\n";
}
generatedCode += "; global variables\n";
for (int i = 0; i < globalVariables.size(); i++) {
Statement stmt = globalVariables.get(i);
if (stmt != null) {
generatedCode = stmt.generateTasm(generatedCode);
generatedCode += "__start:\n";
generatedCode += "; global variables\n";
for (int i = 0; i < globalVariables.size(); i++) {
Statement stmt = globalVariables.get(i);
if (stmt != null) {
generatedCode = stmt.generateTasm(generatedCode);
}
}
}

if (!isImportedFile) {

generatedCode += "\n\n";
generatedCode += "push 0 ; argc\n"; // for simulating argc and argv for now
// generatedCode += "push 0 ; argv\n";
Expand Down
6 changes: 1 addition & 5 deletions src/tile/ast/expr/ArrayIndexAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ private String genLoadCode(String generatedCode) {
public String generateTasm(String generatedCode) {
generatedCode = genLoadCode(generatedCode);
generatedCode += " deref ; dereferance\n";
generatedCode += " derefb " + typeInfo.element_size + " ; dereferance\n";
generatedCode = indicies.get(0).generateTasm(generatedCode);
generatedCode += " push " + typeInfo.element_size + "\n";
generatedCode += " mult\n";
generatedCode += " add\n";
generatedCode += " derefb " + typeInfo.element_size + " ; dereferance\n";
return generatedCode;


// generatedCode += " derefb " + typeInfo.element_size + " ; dereferance\n";
// generatedCode += " deref ; dereferance\n";
}

@Override
Expand Down