# HG changeset patch # User William Morgan # Date 1342301930 25200 # Node ID 8435bf0360f87819bb10e7862c919dc1899cce8b # Parent 75a005b210c51e507180567212f1649bd78dcdf8# Parent a90992bc7331bf6fb5c304b158055d0cce7c0cce merge diff -r 75a005b210c5 -r 8435bf0360f8 Makefile --- a/Makefile Sat Jul 14 14:38:21 2012 -0700 +++ b/Makefile Sat Jul 14 14:38:50 2012 -0700 @@ -5,6 +5,11 @@ OBJS := $(addprefix $(OBJDIR)/,sim.tp.c lifter.tp.c) TPDIR := ../tabletprog TPC := $(TPDIR)/tpc.js +TPFLAGS := + +ifdef compilerdebug + TPFLAGS += -compilerdebug +endif all : $(BINS) $(OBJS) @@ -12,8 +17,13 @@ gcc -ggdb -I$(TPDIR) -o $@ $< $(TPDIR)/runtime/object.c $(OBJDIR)/%.tp.c : $(SRCDIR)/%.tp - d8 $(TPC) -- -basedir $(TPDIR)/ $< > $@ + d8 $(TPC) -- -basedir $(TPDIR)/ -i src $(TPFLAGS) $< > $@ clean : - rm -f $(OBJS) - rm -f $(BINS) + rm -f $(OBJS) $(BINS) + +cleansim : + rm -f bin/sim build/sim.tp.c + +cleanlift : + rm -f bin/lifter build/lifter.tp.c diff -r 75a005b210c5 -r 8435bf0360f8 maps/trampoline4.map --- a/maps/trampoline4.map Sat Jul 14 14:38:21 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ - ###### - #....# - #.**.# - #.**.# - #.**.# -######.\\.###### -#**....*.......# -#\\....L\\\....# -#A......*****..# -######R.....########### - ###.....*.....\\\# - #\\\\#..1...\\\# - #\\\\#......\\\# - ################ - -Trampoline A targets 1 diff -r 75a005b210c5 -r 8435bf0360f8 src/lifter.tp --- a/src/lifter.tp Sat Jul 14 14:38:21 2012 -0700 +++ b/src/lifter.tp Sat Jul 14 14:38:50 2012 -0700 @@ -1,5 +1,21 @@ #{ + true <- #{ + if:else <- :self trueblock :elseblock { + trueblock: + } + } + + false <- #{ + if:else <- :self trueblock :elseblock { + elseblock: + } + } + main <- { - 0 + text <- sim readFd: 0 + playfield <- (sim state) fromStr: text + os write: 2 text + os write: 2 "width: " . (string: (playfield width)) . "\n" + os write: 2 "height: " . (string: (playfield height)) . "\n" } } diff -r 75a005b210c5 -r 8435bf0360f8 src/sim.tp --- a/src/sim.tp Sat Jul 14 14:38:21 2012 -0700 +++ b/src/sim.tp Sat Jul 14 14:38:50 2012 -0700 @@ -196,8 +196,7 @@ } } - readFile <- :path { - fd <- os open: path (os O_RDONLY) + readFd <- :fd { if: fd < 0 { "" } else: { cur <- "" part <- "" @@ -207,11 +206,17 @@ } do: { cur <- cur . part } - os close: fd cur } } + readFile <- :path { + fd <- os open: path (os O_RDONLY) + out <- readFd: fd + os close: fd + out + } + getMove <- { os read: 0 1 }