~swisschili/bluejay

0fc3f26c14e9a24896246d81e2b51b176c968d8b — swissChili 9 months ago fc5c941 jmk2-tcl
Begin Jmk2 in TCL
2 files changed, 122 insertions(+), 0 deletions(-)

A share/jmk/jmk.tcl
A src/lisp/Jmk2
A share/jmk/jmk.tcl => share/jmk/jmk.tcl +89 -0
@@ 0,0 1,89 @@
# Rewrite of JMK in TCL

variable jmk_name {}
variable jmk_target {}
variable cflags {}
variable asmflags {}

variable asm as
variable cc cc

variable options

proc init {name {target {DEFAULT_TARGET}}} {
	if {$target eq {DEFAULT_TARGET}} {
		set target $name
	}

	global jmk_name
	global jmk_target

	set jmk_name $name
	set jmk_target $target
}

proc preset {p} {
	::preset::$p
}

proc presets {args} {
	foreach arg $args {
		preset $arg
	}
}

proc cflag {arg} {
	global cflags
	set cflags "$cflags $arg"
}

proc cflags {args} {
	foreach arg $args {
		cflag $arg
	}
}

proc asmflag {arg} {
	global asmflags 
	set asmflags "$asmflags $arg"
}

proc asmflags {args} {
	foreach arg $args {
		asmflag $arg
	}
}

proc option {name val} {
	global options
	if {![info exists options($name)]} {
		set options($name) $val
	}
}

namespace eval preset {
	proc 32 {} {
		cflag -m32
		asmflag -felf32
	}

	proc debug {} {
		cflag -g
		asmflag -Fdwarf
	}

	proc warn {} {
		cflag "-Wall -Wextra -Werror"
	}

	proc nasm {} {
		global asm
		set asm nasm
	}
}

if {[catch {array set options $argv} msg]} {
	puts "Sorry, you must pass an even number of arguments to this script"
	puts "in the form <key> <value>"
	exit 1
}

A src/lisp/Jmk2 => src/lisp/Jmk2 +33 -0
@@ 0,0 1,33 @@
# -*- mode:tcl -*-

source "../../share/jmk/jmk.tcl"

init lisp

presets 32 debug warn nasm
cflags -Ivendor/luajit/dynasm -O0

option NO_READLINE 0

type executable

if {$options(NO_READLINE) == 0} {
	cflags -lreadline
} else {
	cflags -DNO_READLINE
}

set lua vendor/luajit/src/host/minilua

rule $lua ${lua}.c {
	log CC $source
	cc $source -o $target -lm
}

rule compiler.c "compiler.dasc $lua" {
	log DYNASM $first_source
	shell $::lua vendor/luajit/dynasm/dynasm.lua -o $target $first_source
}

sources main.c lisp.c compiler.c lib/std.c plat/linux.c istream.c gc.c \
	call_list.s error.c