development/kforth: Added (A Forth programming language and environment)

Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
This commit is contained in:
G. Schoenmakers 2013-02-23 23:00:15 -06:00 committed by Robby Workman
parent 86ef446c7f
commit d34c34353b
6 changed files with 231 additions and 0 deletions

View File

@ -0,0 +1,78 @@
Index: ForthVM.cpp
===================================================================
--- ForthVM.cpp (revision 7)
+++ ForthVM.cpp (working copy)
@@ -155,6 +155,14 @@
// PUSH_IVAL and PUSH_ADDR
// 2011-02-06 km fixed problem with FS. not restoring original precision.
// 2011-03-05 km removed commented out code which was replaced by macros.
+// 2011-03-10 km added global string dir_env_var to allow default directory
+// environment variable to be specified externally, in the
+// Makefile.
+// 2011-11-01 km revised CPP_allot to ensure all created words which have
+// ALLOTed memory also have appropriate execution code;
+// This change also allows removal of common code from
+// CPP_variable and CPP_fvariable.
+const char* dir_env_var=DIR_ENV_VAR;
#include <string.h>
#include <stdlib.h>
@@ -1550,6 +1558,13 @@
{
id->Pfa = new byte[n];
if (id->Pfa) memset (id->Pfa, 0, n);
+
+ // Provide execution code to the word to return its Pfa
+ byte *bp = new byte[6];
+ id->Cfa = bp;
+ bp[0] = OP_ADDR;
+ *((int*) &bp[1]) = (int) id->Pfa;
+ bp[5] = OP_RET;
}
else
return E_V_REALLOT;
@@ -1642,14 +1657,7 @@
DEC_DSP
STD_IVAL
int e = CPP_allot();
- if (e) return e;
- WordIndex id = pCompilationWL->end() - 1;
- byte *bp = new byte[6];
- id->Cfa = bp;
- bp[0] = OP_ADDR;
- *((int*) &bp[1]) = (int) id->Pfa;
- bp[5] = OP_RET;
- return 0;
+ return e;
}
//-----------------------------------------------------------------
@@ -1662,14 +1670,7 @@
DEC_DSP
STD_IVAL
int e = CPP_allot();
- if (e) return e;
- WordIndex id = pCompilationWL->end() - 1;
- byte *bp = new byte[6];
- id->Cfa = bp;
- bp[0] = OP_ADDR;
- *((int*) &bp[1]) = (int) id->Pfa;
- bp[5] = OP_RET;
- return 0;
+ return e;
}
//------------------------------------------------------------------
@@ -2464,10 +2465,10 @@
ifstream f(filename);
if (!f)
{
- if (getenv("KFORTH_DIR"))
+ if (getenv(dir_env_var))
{
char temp[256];
- strcpy(temp, getenv("KFORTH_DIR"));
+ strcpy(temp, getenv(dir_env_var));
strcat(temp, "/");
strcat(temp, filename);
strcpy(filename, temp);

View File

@ -0,0 +1,48 @@
Index: Makefile
===================================================================
--- Makefile (revision 7)
+++ Makefile (working copy)
@@ -31,6 +31,9 @@
# 2011-03-05 km; revised archive and snapshot rules to exclude version
# control subdirectories in the archive files (since we
# now using Subversion for source control)
+# 2011-03-10 km; define name of environment variable containing default
+# Forth source directory, and pass to compiler.
+# 2011-11-01 km; updated version to 1.5.2p1
#
# Possible invocations:
#
@@ -50,7 +53,8 @@
# Invoke "make debug" if you want to create an executable
# that contains debugging information for the GNU debugger (gdb).
-VERSION = 1.5.2
+VERSION = 1.5.2p1
+DEF_DIR_VAR=KFORTH_DIR
BUILD_DATE=`date +%F`
DEBUG =
TARGET_CPU = x86
@@ -64,7 +68,7 @@
CPP = ${GCCDIR}/g++
CC = ${GCCDIR}/gcc
-CPPFLAGS = -c -m32
+CPPFLAGS = -c -m32
CFLAGS = -c -m32
FAST = -D__FAST__
OBJS = kforth.o ForthVM.o ForthCompiler.o vm.o vmc.o
@@ -118,10 +122,12 @@
${CPP} ${CPPFLAGS} ${DEBUG} ForthCompiler.cpp
ForthVM.o: ForthVM.cpp ForthVM.h fbc.h ForthCompiler.h kfmacros.h
- ${CPP} ${CPPFLAGS} ${DEBUG} ForthVM.cpp
+ ${CPP} ${CPPFLAGS} -DDIR_ENV_VAR=\"${DEF_DIR_VAR}\" \
+ ${DEBUG} ForthVM.cpp
ForthVM-fast.o: ForthVM.cpp ForthVM.h fbc.h ForthCompiler.h kfmacros.h
- ${CPP} ${CPPFLAGS} ${DEBUG} ${FAST} -o ForthVM-fast.o ForthVM.cpp
+ ${CPP} ${CPPFLAGS} -DDIR_ENV_VAR=\"${DEF_DIR_VAR}\" \
+ ${DEBUG} ${FAST} -o ForthVM-fast.o ForthVM.cpp
vmc.o: vmc.c kfmacros.h
${CC} ${CFLAGS} ${DEBUG} vmc.c

10
development/kforth/README Normal file
View File

@ -0,0 +1,10 @@
kForth is an implementation of the Forth programming language and
environment. The user may write Forth programs with an editor,
load these program files from kForth, and run them. kForth, like
other implementations of Forth, provides an interactive environment,
allowing the user to examine or define variables and execute or
define individual words.
kForth is designed to be installed on a 32-bit linux operating system.
It will not install on 64-bit Slackware unless multilib support is
installed.

View File

@ -0,0 +1,66 @@
#!/bin/sh
# Slackware build script for kforth
# Written by G. Schoenmakers <gschoen@iinet.net.au>
PRGNAM=kforth
VERSION=${VERSION:-1.5.2}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
MODEL=${MODEL:-x86-linux}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$MODEL-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
patch ForthVM.cpp $CWD/ForthVM.diff
patch Makefile $CWD/Makefile.diff
VERSION=${VERSION}p1
make
# There is no "make install" so the following instructions are used to copy
# the relevant files into the $PKG directory.
mkdir -p $PKG/usr/bin
cp -a kforth $PKG/usr/bin
cp -a kforth-fast $PKG/usr/bin
mkdir -p $PKG/usr/share/pixmaps
cp -a kforth.xpm $PKG/usr/share/pixmaps
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a ChangeLog README examples $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

View File

@ -0,0 +1,10 @@
PRGNAM="kforth"
VERSION="1.5.2p1"
HOMEPAGE="http://ccreweb.org/software/kforth/kforth.html"
DOWNLOAD="ftp://ccreweb.org/software/kforth/linux/kforth-x86-linux-1.5.2.tar.gz"
MD5SUM="8def6b906289fc2f2b404a7be8e8d9ce"
DOWNLOAD_x86_64="UNTESTED"
MD5SUM_x86_64=""
REQUIRES=""
MAINTAINER="G. Schoenmakers"
EMAIL="gschoen@iinet.net.au"

View File

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
kforth: kforth (A Forth programming language and environment)
kforth:
kforth: kForth is an implementation of the Forth programming language and
kforth: environment. The user may write Forth programs with an editor,
kforth: load these program files from kForth, and run them. kForth, like
kforth: other implementations of Forth, provides an interactive environment,
kforth: allowing the user to examine or define variables and execute or
kforth: define individual words.
kforth:
kforth: http://ccreweb.org/software/kforth/kforth1.html
kforth: