Commit 66568b2b authored by kollo's avatar kollo

version 1.14

parent 4581463c
......@@ -154,4 +154,9 @@ Version 1.13 (Feb 2006)
- fixed bug in PAUSE/DELAY
- implemented ioctl() function
Version 1.14 (Apr 2007)
~~~~~~~~~~~~~~~~~~~~~~~~
--------------------------------------------------------------------------------
Release notes for Version 1.13 (Feb 2006)
Release notes for Version 1.14 (Apr 2007)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- fixed bug in INPUT$()
- woked in the TINE implementation (TINELISTEN, TINEBROADCAST)
- new MKA$(), CVA()
- fixed bug in PAUSE/DELAY
- implemented ioctl() function
- improved the init_program routines
- woked on the bytecode compiler
- new programs xbbc and xbvm + man pages
- the bytecodecompiler and virtual machine are still full of bugs
- some sample programs can already be compiled to bytecode,
they run 4 to 10 times faster
- Bug fixed which caused "Command not allowed in interactive mode" errors
This bug was introduced in Version 1.14 since release 1
......@@ -11,9 +11,9 @@
###############################################################
VERSION 1.13
VERSION 1.14
(C) 1997-2006 by Markus Hoffmann
(C) 1997-2007 by Markus Hoffmann
(kollo@users.sourceforge.net)
(see http://x11-basic.sourceforge.net/)
......@@ -23,7 +23,7 @@
See the file `COPYING' for licensing information
Last change to this file: Do Mär 15 20:46:41 CET 2007
Last change to this file: Sa Mai 12 22:23:14 CEST 2007
==> <==
X11-Basic is a comprehensive non-standard Basic inter­
......@@ -261,15 +261,32 @@ SuSE-Linux and RedHat
-rw-r--r-- 164366 X11-Basic-manual.txt -- the manual
drwxr-xr-x 1024 editors/ -- files for editors
drwxr-xr-x 1024 examples/ -- few example programs
Debian based distributions
As with Ubuntu linux the popularity of debian based linux distributions has
dramatically increases in the recent past. RPM is not used for debian based
distributions. But with the RPM to DEB converter alien, a .deb package can
be created out of the .rpm files. If you hesitate to do so, there are also
ready-made debian packages available on various sources. You just need to
look for them on the internet. Al though they are maintained by third party
volunteers, the file system structure should be similar to what is described
in the previous chapter, so you should expect to find the same files at the
same place.
Other linux distributions
Maybe RPM is supported for your distribution, then you can follow the
instructions above. If not, you might look for a debian package or a
package for HPUX. So far there exist no packages for any other system.
Maybe RPM is supported for your distribution, then you can follow the
instructions above. If not, you might look for a debian package. Also the
existence of a package for HPUX is known (unfortunately it contains the very
old version 1.04 and seems not to be maintained any more). So far (as I
know) there exist no packages for any other system.
For all other systems you will have to get the source-package
X11Basic-1.09.tar.gz and compile the sources (which is very easy, by
X11Basic-1.14.tar.gz and compile the sources (which is very easy, by
the way). This should work for all linux distributions, and probably
with little modifications also for HPUX, for DEC/alpha and FreeBSD and
maybe others.
......@@ -344,6 +361,29 @@ make the pseudo-compiler work, libraries
After doing all this, you will also find a xbasic.dyn executabe. This
is the interpreter, dynamically linked and much shorter.
The bytecode compiler and the virtual machine
Both programs xbbc and xbbc are new to this package. The idea is to increase
the excecution speed of X11-basic programs a lot by compiling it to a
bytecode before execution. The bytecode then can be run much faster with the
bytecode interpreter, the so-called virtual machine. The conversion to
bytecode is a real compilation (in contrast to what the pseudo compiler
xbc does). The step to assembler or machine code is not far. Also a
conversion to C or to JAVA or any other language will be straigt forward,
although the code will practically not be readable to humans anymore. As with
JAVA, the bytecode is still platform independant and can be run on any
system, which has a virtual machine ported to.
One point to mention (whether this is a feature or a disadvantage):
X11-basic bytecode can not be converted back to source code (.bas).
Because this is a new feature which is incomplete and still has a lot of bugs
the feature is not incorporated into the interpreter xbasic itself.
Please try the bytecode compiler out and maybe you want to report errors
etc.
Support
If you have trouble with X11-Basic, you may send me a mail or browse
......@@ -1717,7 +1757,7 @@ XXXX \= X11-Basic Error messages: \kill \\
92 \> Resume (next) nicht möglich Fatal, For oder Local\\
93 \> Stapel-Fehler\\
100 \> X11BASIC Version 1.13 Copyright (c) 1997-2006 Markus Hoffmann\\
100 \> X11BASIC Version 1.14 Copyright (c) 1997-2007 Markus Hoffmann\\
101 \> ** 1 - Segmentation fault : Speicherschutzverletzung\\
102 \> ** 2 - Bus Error Peek/Poke falsch?\\
103 \> ** 3 - Adress error Ungerade Wort-Adresse! Dpoke/Dpeek, Lpoke/Lpeek?\\
......@@ -7044,6 +7084,11 @@ Version 1.13 (Feb 2006)
- fixed bug in PAUSE/DELAY
- implemented ioctl() function
Version 1.14 (Apr 2007)
~~~~~~~~~~~~~~~~~~~~~~~~
--------------------------------------------------------------------------------
*Acknowlegements
......
.TH XBBC 1 09-Apr-2007 "Version 1.14" "Linux Basic Compiler"
.SH NAME
xbbc (X11-Basic bytecode compiler) \- X11-Basic bytecode compiler
.SH SYNOPSIS
.B xbbc
.RI "[ " option " ] " <filename>
.SH DESCRIPTION
X11-Basic is a comprehensive non-standard Basic interpreter with full X
capability that integrates fratures like shell scripting, cgi-Programming and
full graphical visualisation into the easy to learn basic language on moden
computers.
.IR xbbc
can be used to make bytecode-binaries out of *.bas script-Files. These bytecode
files can be interpreted by the X11-Basic virtual machine (
.I xbvm(1)
) and they run about 4 to 10 times faster than the interpreted .bas files. Since
.I xbbc
is a real compiler (compared to the X11-Basic psydo-compiler (
.I xbc
)), some restrictions to the code apply.
.B For a desciption of the X11-basic language and Usage of the interpreter see
.I xbasic(1).
.SH Filenames
Xbbc processes one input file. The Suffix of the input file is usually .bas.
The default output file name is
.I b.b
but you can specify alternate names with the -o option.
.SH OPTIONS
.TP
.BI "\-o " file
Place output in file \c
.I file\c
\&. This applies regardless to whatever
sort of output xbbc is producing.
.Sp
Since only one output file can be specified, it does not make sense to
use `\|\c
.B \-o\c
\&\|' when compiling more than one input file, unless you are
producing an executable file as output.
.Sp
If you do not specify `\|\c
.B \-o\c
\&\|', the default is to put an executable file
in `\|\c
.B b.b\c
.
.SS \--version
shows version, program and other information and exits
.SS -h --help
print a short help
For detailed help and description of the implemented basic commands take a
look at the README file.
.SH EXAMPLES
.nf
xbbc testme.bas
produces a bytecode file b.b
xbbc testme.bas -o testme
produces a bytecode file testme
.fi
You can find many sample programs in
.I /usr/share/doc/packages/X11Basic/examples.
.SH The bytecode compiler
Actually this compiler is really a
compiler, all though the bytecode must be interpreted on runtime.
This interpreter is highly optimized, so that the gain in
excecution speed is immense. Especially complex formulas are
speed up by a factor 10.
There is no way to recreate the source code from the bytecode.
But still the bytecode is platform independant.
.SH VERSION
Page was created for V.1.14
.SH BUG REPORTS
If you find a bug in the X11-Basic bytecode compiler, you should
report it. But first, you should make sure that it really is
a bug, and that it appears in the latest version of the
X11-Basic package that you have.
Once you have determined that a bug actually exists, mail a
bug report to kollo@users.sourceforge.net. If you have a fix,
you are welcome to mail that as well! Suggestions may
be mailed to the x11-basic mailing list on
www.sourceforge.net/projects/x11-basic or posted to the bug
tracking system.
Comments and bug reports concerning this manual page
should be directed to kollo@users.sourceforge.net.
.SH BUGS
Still some bugs
.SH AUTHOR
Markus Hoffmann <kollo@users.sourceforge.net>
.SH COPYRIGHT
Copyright (C) 1997-2007 Markus Hoffmann <kollo@users.sourceforge.net>
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more
details.
.SH SEE ALSO
xbasic(1), xbvm(1), xbc(1)
.TH XBVM 1 09-Apr-2007 "Version 1.14" "Linux Basic Compiler"
.SH NAME
xbvm (X11-Basic virtual machine) \- X11-Basic bytecode interpreter
.SH SYNOPSIS
.B xbvm
.RI "[ " option " ] " <filename>
.SH DESCRIPTION
X11-Basic is a comprehensive non-standard Basic interpreter with full X
capability that integrates fratures like shell scripting, cgi-Programming and
full graphical visualisation into the easy to learn basic language on moden
computers.
.IR xbvm
can be used to execute bytecode-binaries which where compiled with
.I xbbc(1)
. These bytecode
files run about 4 to 10 times faster than the interpreted .bas files.
.B For a desciption of the X11-basic language and Usage of the interpreter see
.I xbasic(1).
.SH Filenames
Xbvm processes one input file. The Suffix of the input file is usually .b.
.SH OPTIONS
.TP
.BI "\-q "
Be quiet and print less debug information
.
.SS \--version
shows version, program and other information and exits
.SS -h --help
print a short help
For detailed help and description of the implemented basic commands take a
look at the README file.
.SH EXAMPLES
.nf
xbvm testme.b
xbbc -q testme.b
.fi
You can find many sample programs in
.I /usr/share/doc/packages/X11Basic/examples.
.SH The virtual machine
Actually this interpreter is a stack machine. The bytecode is very compact and similar
to machine code. It would not be a big step to compile it to assembler.
This interpreter is highly optimized, so that the gain in
excecution speed is immense. Especially complex formulas are
speed up by a factor 10.
There is no way to recreate the source code from the bytecode.
But still the bytecode is platform independant.
.SH VERSION
Page was created for V.1.14
.SH BUG REPORTS
If you find a bug in the X11-Basic virtual machine, you should
report it. But first, you should make sure that it really is
a bug, and that it appears in the latest version of the
X11-Basic package that you have.
Once you have determined that a bug actually exists, mail a
bug report to kollo@users.sourceforge.net. If you have a fix,
you are welcome to mail that as well! Suggestions may
be mailed to the x11-basic mailing list on
www.sourceforge.net/projects/x11-basic or posted to the bug
tracking system.
Comments and bug reports concerning this manual page
should be directed to kollo@users.sourceforge.net.
.SH BUGS
Still some bugs
.SH AUTHOR
Markus Hoffmann <kollo@users.sourceforge.net>
.SH COPYRIGHT
Copyright (C) 1997-2007 Markus Hoffmann <kollo@users.sourceforge.net>
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more
details.
.SH SEE ALSO
xbasic(1), xbbc(1), xbc(1)
......@@ -4,12 +4,15 @@
' (c) Markus Hoffmann Dec. 2002 (letzte Bearbeitung: 10.09.2005)
' 10.2004: Produziert nun auch Object-Files ohne main()
' 10.2005: Produziert nun auch WINDOWS .exe files
' 04.2007: now can produce .b bytecode files
i=1
compileonly=FALSE
precomponly=FALSE
lflag=FALSE
win32=FALSE
bytecode=FALSE
virtualm=FALSE
CLR inputfile$,dyn,collect$
outputfilename$="b.out"
WHILE LEN(param$(i))
......@@ -27,6 +30,10 @@ WHILE LEN(param$(i))
if outputfilename$="b.out"
outputfilename$="b.exe"
endif
ELSE IF param$(i)="-bytecode"
bytecode=true
ELSE IF param$(i)="-virtualm"
virtualm=true
ELSE IF param$(i)="-b"
precomponly=TRUE
compileonly=TRUE
......@@ -61,8 +68,20 @@ IF LEN(inputfile$)
wort_sep a$,".",1,rumpf$,typ$
if typ$="o"
@link
else if typ$="b"
@compilevm
if not compileonly
@link
endif
else if typ$="bas"
@compile
if virtualm or bytecode
@dobytecode
endif
if virtualm
@compilevm
else
@compile
endif
if not compileonly
@link
endif
......@@ -74,7 +93,7 @@ else
ENDIF
QUIT
PROCEDURE intro
PRINT "X11-Basic Compiler V.@version@ (c) Markus Hoffmann 2002-2004"
PRINT "X11-Basic Compiler V.@version@ (c) Markus Hoffmann 2002-2007"
VERSION
RETURN
PROCEDURE using
......@@ -86,10 +105,34 @@ PROCEDURE using
PRINT " -b only precompile"
PRINT " -c precompile and compile, but do not link"
PRINT " -l produce linkable object file (no executable)"
PRINT " -bytecode produce a bytecode file"
PRINT " -virtualm use virtual machine framework insted of psydo-interpreter"
PRINT " -shared produce shared object file"
PRINT " -win32 produce Windows .exe file"
PRINT " -o <file> Place the output into <file>"
RETURN
procedure dobytecode
system "cbbc -o "+rumpf$+".b"+" "+inputfile$
return
procedure compilevm
open "O",#2,rumpf$+".c"
print #2,"/* PSEUDO-Code-VM.c ("+f$+")"
print #2," X11-BAsic-Pseudo-Compiler Version @version@"
print #2," (c) Markus Hoffmann"
print #2,"*/"
print "Sorry, bytecode files can not be compiled to any other"
print "format yet. Use xbvm to run them."
CLOSE #2
IF NOT precomponly
if win32
system "i686-pc-mingw32-gcc @copt@ -c "+rumpf$+".c"
else
system "@CC@ @copt@ -c "+rumpf$+".c"
endif
system "rm -f "+rumpf$+".c"
ENDIF
return
procedure compile
open "O",#2,rumpf$+".c"
print #2,"/* PSEUDO-Code.c ("+f$+")"
......
' Simple test for the virtual Machine
print "Los gehts..."
' ~inp(-2)
color get_color(65535,65535,0)
text 30,360,"Test of the X11-Basic virtual machine"
do
i=(i+1) mod 640
color get_color(random(65535),random(65535),random(65535))
pbox random(300),random(0),random(640),random(300)
showpage
if i=0
print timer-t;" sek."
t=timer
endif
plot i,50*sin(i/100*2*pi)+350
' pause 0.1
loop
quit
......@@ -4,13 +4,17 @@
4513 Sep 18 2001 <a href="3Dng.bas">3Dng.bas</a> (<a href="../../screenshots/3dng.png">Screenshot</a>)
2475 May 4 2002 <a href="RDS.bas">RDS.bas</a> (<a href="../../screenshots/RDS1.png">Screenshot</a>)
3265 Jan 4 2003 <a href="ana_uhr.bas">ana_uhr.bas</a> (<a href="../../screenshots/ana_uhr.png">Screenshot</a>)
413 Jan 4 2007 <a href="boxes.bas">boxes.bas</a>
768 Jan 4 2003 <a href="conv_bmp.bas">conv_bmp.bas</a>
697 Nov 4 2004 <a href="draw.bas">draw.bas</a>
385 Apr 4 1999 <a href="elli1.bas">elli1.bas</a> (<a href="../../screenshots/elli1.png">Screenshot</a>)
2549 Oct 20 2002 <a href="kugel.bas">kugel.bas</a> (<a href="../../screenshots/kugel.png">Screenshot</a>)
923 Feb 7 2003 <a href="mandel.bas">mandel.bas</a> (<a href="../../screenshots/mandel.png">Screenshot</a>)
575 Feb 7 2007 <a href="mandelbenchmark.bas">mandelbenchmark.bas</a>
885 Feb 6 1998 <a href="netzgraf.bas">netzgraf.bas</a> (<a href="../../screenshots/netzgraf.png">Screenshot</a>)
353 Jan 4 2003 <a href="plot.bas">plot.bas</a> (<a href="../../screenshots/plot.png">Screenshot</a>)
1169 Sep 4 2001 <a href="space.bas">space.bas</a> (<a href="../../screenshots/space.png">Screenshot</a>)
643 Sep 4 2006 <a href="sattrac1.bas">sattrac1.bas</a> Strange Attractor
1195 Feb 28 00:36 <a href="wurm.bas">wurm.bas</a> (<a href="../../screenshots/wurm.png">Screenshot</a>)
233 Oct 20 2002 <a href="zoom.bas">zoom.bas</a> (<a href="../../screenshots/zoom.png">Screenshot</a>)
283 Oct 20 2002 <a href="zoom2.bas">zoom2.bas</a> (<a href="../../screenshots/zoom2.png">Screenshot</a>)
......
'
' A Fractal as a benchmark for the X11-basic virtual machine
' (c) Markus Hoffmann 2007
'
bx=0
by=0
bw=256
bh=256
sx=-2.2
sy=-1.5
sw=2
sh=2
sizew ,bw,bh
t=timer
while y<bh
gx=(x-bx)/bw*sw+sx
gy=(y-by)/bh*sh+sy
zx=gx
zy=gy
c=0
while c<256
nzx=zx^2-zy^2+gx
zy=2*zx*zy+gy
zx=nzx
if zx^2+zy^2>4
goto out
endif
c=c+1
wend
out:
if c<256
color get_color(c*256,c*512,c*1024)
plot x,y
endif
x=x+1
if x=bw
x=0
y=y+1
showpage
print y
endif
wend
print timer-t
~inp(-2)
quit
......@@ -45,7 +45,7 @@ DATADIR=@datadir@
LIBDIR=@libdir@
MANDIR=@mandir@
OBJS= xbasic.o file.o ccs.o io.o parser.o variablen.o\
OBJS= xbasic.o file.o ccs.o io.o parser.o variablen.o array.o\
runtime.o wort_sep.o ltext.o functions.o\
kommandos.o gkommandos.o do_gets.o errortxt.o window.o\
sysVstuff.o
......@@ -61,8 +61,8 @@ DEPSRC= $(CSRC)
# Headerfiles which should be added to the distribution
HSRC= defs.h file.h functions.h gkommandos.h globals.h kommandos.h \
options.h protos.h xbasic.h window.h vtypes.h ptypes.h
HSRC= array.h defs.h file.h functions.h gkommandos.h globals.h kommandos.h \
options.h protos.h xbasic.h window.h vtypes.h ptypes.h bytecode.h
DIST= README INSTALL COPYING install.sh doc/man-pages/*.1 doc/ACKNOWLEGEMENTS \
......@@ -75,6 +75,7 @@ DIST= README INSTALL COPYING install.sh doc/man-pages/*.1 doc/ACKNOWLEGEMENTS \
src/io.c \
src/parser.c \
src/variablen.c \
src/array.c src/array.h \
src/mathemat_dummy.c \
src/runtime.c \
src/wort_sep.c \
......@@ -89,11 +90,14 @@ DIST= README INSTALL COPYING install.sh doc/man-pages/*.1 doc/ACKNOWLEGEMENTS \
src/errortxt.c \
src/window.c \
src/sysVstuff.c \
src/bytecode.c \
src/virtual-machine.c \
src/xbvm.c \
src/defs.h src/config.h.in \
src/globals.h \
src/xbasic.h src/fdata.c \
src/window.h src/file.h src/protos.h src/options.h \
src/Makefile.in src/ptypes.h src/vtypes.h\
src/Makefile.in src/ptypes.h src/vtypes.h src/bytecode.h\
src/configure \
src/config.guess \
src/configure.in\
......@@ -237,6 +241,14 @@ myzip : xbc
xbc ../examples2/utils/myunzip.bas --dynamic -o myunzip
strip myzip
strip myunzip
bytecode : bytecode.h bytecode.c virtual-machine.o
gcc -o $@ bytecode.c virtual-machine.o -lx11basic -lm -L /usr/X11/lib/ -lX11 -lreadline
bytecodestatic : bytecode.h bytecode.c virtual-machine.o x11basic.a
gcc -o bytecode bytecode.c virtual-machine.o x11basic.a -lm -L /usr/X11/lib/ -lX11 -lreadline
xbvm : bytecode.h xbvm.c virtual-machine.o bytecode.h
gcc -o $@ xbvm.c virtual-machine.o -lx11basic -lm -L /usr/X11/lib/ -lX11 -lreadline
xbvmstatic : bytecode.h xbvm.c virtual-machine.o bytecode.h x11basic.a
gcc -o xbvm xbvm.c virtual-machine.o x11basic.a -lm -L /usr/X11/lib/ -lX11 -lreadline
installhome : xbasic
install -s -m 755 xbasic ${HOME}/bin/xbasic
installdyn : dyn lib
......@@ -246,11 +258,11 @@ install : dyn lib x11basic.a
install -s -m 755 xbasic.dyn $(BINDIR)/xbasic
install -m 755 libx11basic.so $(LIBDIR)/
install -m 644 x11basic.a $(LIBDIR)/
install -m 644 ../man-pages/x11basic.1 $(MANDIR)/man1/x11basic.1
install -m 644 ../man-pages/x11basic.1 $(MANDIR)/man1/xbasic.1
install -m 644 ../doc/man-pages/x11basic.1 $(MANDIR)/man1/x11basic.1
install -m 644 ../doc/man-pages/x11basic.1 $(MANDIR)/man1/xbasic.1
xbcinstall : xbc install
install -s -m 755 xbc $(BINDIR)/
install ../man-pages/xbc.1 $(MANDIR)/man1/xbc.1
install ../doc/man-pages/xbc.1 $(MANDIR)/man1/xbc.1
uninstall :
rm -f $(LIBDIR)/libx11basic.so
rm -f $(LIBDIR)/x11basic.a
......@@ -258,7 +270,7 @@ uninstall :
rm -f $(MANDIR)/man1/xbasic.1
rm -f $(MANDIR)/man1/x11basic.1 $(MANDIR)/man1/xbc.1
clean :
rm -f xbasic xbasic.dyn xbasic.static xbc *.o *.so a.out *.a \
rm -f xbasic xbasic.dyn xbasic.static xbc xbvm bytecode *.o *.so a.out *.a \
myzip myunzip bas2x11basic X11-Basic-examples-@version@.tar.myz \
X11-Basic-examples-@version@.tar
......
/* array.c (c) Markus Hoffmann */
/* This file is part of X11BASIC, the basic interpreter for Unix/X
* ============================================================
* X11BASIC is free software and comes with NO WARRANTY - read the file
* COPYING for details
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "defs.h"
#include "xbasic.h"
#include "array.h"
#include "protos.h"
/******************** Array variable by name routines **************************/
void array_zuweis_and_free(char *name, ARRAY inhalt) {
int typ,vnr;
char *r=varrumpf(name),*a=argument(name);
char *nam;
int ztyp=vartype(name);
vnr=variable_exist(r,inhalt.typ | ARRAYTYP);
typ=inhalt.typ;
if(ztyp!=(typ|ARRAYTYP)) {
if((ztyp & FLOATTYP) && (typ & INTTYP)) {
if(vnr==-1) {
if(a[0]==0) neue_array_variable_and_free(r,convert_to_floatarray(inhalt), 0);
else error(15,name); /* Feld nicht dimensioniert */
free_array(inhalt);
} else {
if(a[0]==0) feed_array_and_free(vnr,convert_to_floatarray(inhalt));
else feed_subarray_and_free(vnr,a,convert_to_floatarray(inhalt));
free_array(inhalt);
}
} else if((ztyp & INTTYP) && (typ & FLOATTYP)) {
if(vnr==-1) {
if(*a==0) neue_array_variable_and_free(r,convert_to_intarray(inhalt), 0);
else error(15,name); /* Feld nicht dimensioniert */
free_array(inhalt);
} else {
if(*a==0) feed_array_and_free(vnr,convert_to_intarray(inhalt));
else feed_subarray_and_free(vnr,a,convert_to_intarray(inhalt));
free_array(inhalt);
}
} else {
puts("ERROR: Arrays haben nicht dengleichen Typ!");
printf("ztyp=%d typ=%d\n",ztyp,typ);
printf("ARRAY: Typ=%d\n",inhalt.typ);
printf(" dim=%d\n",inhalt.dimension);
printf(" ptr=%d\n",inhalt.pointer);
}
} else {
if(vnr==-1) {
if(a[0]==0) neue_array_variable_and_free(r, inhalt, sp);
else error(15,name); /* Feld nicht dimensioniert */
} else {
if(a[0]==0) feed_array_and_free(vnr,inhalt);
else feed_subarray_and_free(vnr,a,inhalt);
}
}
free(r);free(a);
}
char *arrptr(char *n) {
int typ=vartype(n);
char *r=varrumpf(n);
char *ergebnis=NULL;
int vnr=variable_exist(r,typ);
if(vnr==-1) error(15,r); /* Feld nicht dimensioniert */
else ergebnis=variablen[vnr].pointer;
return(ergebnis);
}
/******************** Array variable by vnr routines **************************/
void fill_int_array(int vnr, int inh) {
int anz=do_dimension(vnr),j=0;
int *pp=(int *)(variablen[vnr].pointer+variablen[vnr].opcode*INTSIZE);
while(j<anz) pp[j++]=inh;
}
void fill_float_array(int vnr, double inh) {
int anz=do_dimension(vnr),j=0;
double *pp=(double *)(variablen[vnr].pointer+variablen[vnr].opcode*INTSIZE);
while(j<anz) pp[j++]=inh;
}
ARRAY copy_var_array(int vnr) {
/* Uebernimmt ein Array aus Variablenliste und gibt es als ARRAY Struktur
zurueck */
/* Es wird kopiert ! */
ARRAY zw;
zw.typ=variablen[vnr].typ&(~ARRAYTYP);
zw.dimension=variablen[vnr].opcode;
zw.pointer=variablen[vnr].pointer;
return(double_array(zw));
}
/* Dasselbe wie copy_var_array, es wird aber nicht kopiert ! */
ARRAY array_info(int vnr) {
ARRAY zw;
zw.typ=variablen[vnr].typ&(~ARRAYTYP);
zw.dimension=variablen[vnr].opcode;
zw.pointer=variablen[vnr].pointer;
return(zw);
}
void feed_array_and_free(int vnr, ARRAY wert) {
/* Uebernimmt ein Array des internen Typs in die Variablenliste */
/* Es wird nicht kopiert ! */
/* erst alten Arrayinhalt freigeben */
free_array(array_info(vnr));
/* Dann neuen einklinken */
variablen[vnr].opcode=wert.dimension;
variablen[vnr].pointer=wert.pointer;
variablen[vnr].typ=(wert.typ | ARRAYTYP);
}
void convert_float_to_int_array(int vnr1, int vnr2) {
int anz1=do_dimension(vnr1),j;
int anz2=do_dimension(vnr2);
int anz=min(anz1,anz2);
int *pp1=(int *)(variablen[vnr1].pointer+variablen[vnr1].opcode*INTSIZE);
double *pp2=(double *)(variablen[vnr2].pointer+variablen[vnr2].opcode*INTSIZE);
for(j=0;j<anz;j++) pp1[j]= (int) pp2[j];
}
void convert_int_to_float_array(int vnr1, int vnr2) {
int anz1=do_dimension(vnr1),j;
int anz2=do_dimension(vnr2);
int anz=min(anz1,anz2);
double *pp1=(double *)(variablen[vnr1].pointer+variablen[vnr1].opcode*INTSIZE);
int *pp2=(int *)(variablen[vnr2].pointer+variablen[vnr2].opcode*INTSIZE);
for(j=0;j<anz;j++) pp1[j]=(double)pp2[j];
}