langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,3 @@
foo := Object->New(); // allocates an object on the heap
foo_array := Int->New[size]; // allocates an integer array on the heap
x := 0; // allocates an integer on the stack

View file

@ -0,0 +1 @@
allocatemem(100<<20)

View file

@ -0,0 +1,12 @@
mainproc: proc options(main) reorder;
subproc: proc;
dcl subvar char init ('X');
put skip data(subvar);
subvar = 'Q';
end subproc;
call subproc();
call subproc();
end mainproc;

View file

@ -0,0 +1,17 @@
mainproc: proc options(main) reorder;
dcl ctlvar char ctl;
alloc ctlvar;
ctlvar = 'A';
alloc ctlvar;
ctlvar = 'B';
alloc ctlvar;
ctlvar = 'C';
put skip data(ctlvar);
free ctlvar;
put skip data(ctlvar);
free ctlvar;
put skip data(ctlvar);
free ctlvar;
end mainproc;

View file

@ -0,0 +1,27 @@
mainproc: proc options(main) reorder;
dcl list_ptr ptr init (sysnull());
dcl list_top ptr init (sysnull());
dcl list_end ptr init (addr(list_top));
dcl i fixed bin (31);
dcl 1 list based(list_ptr),
2 list_nxt ptr init (sysnull()),
2 list_data fixed bin (31) init (i);
/*
* Allocate the list
*/
do i = 1 to 4;
alloc list;
list_end -> list_nxt = list_ptr;
list_end = list_ptr;
end;
/*
* Print the list
*/
do list_ptr = list_top repeat list_nxt
while(list_ptr ^= sysnull());
put skip list(list_data);
end;
end mainprog;

View file

@ -0,0 +1,9 @@
type
TByteArray = array of byte;
var
A: TByteArray;
begin
setLength(A,1000);
...
setLength(A,0);
end;

View file

@ -0,0 +1,11 @@
type
Tcl = class
dummy: longint;
end;
var
c1: cl;
begin
c1:=Tcl.create;
...
c1.destroy;
end;

View file

@ -0,0 +1 @@
my $buffer = Buf.new(0 xx 1024);

View file

@ -0,0 +1,15 @@
*buffer=AllocateMemory(20)
*newBuffer = ReAllocateMemory(*buffer, 2000) ;increase size of buffer
;*buffer value is still valid if newBuffer wasn't able to be reallocated
If *newBuffer <> 0
*buffer = *newBuffer : *newBuffer = 0
EndIf
FreeMemory(*buffer)
size=20
; allocate an image for use with image functions
CreateImage(1,size,size)
FreeImage(1)

View file

@ -0,0 +1,14 @@
( display total memory available )
@memory putn
( display unused memory )
@memory here - putn
( display next free address )
here putn
( allocate 1000 cells )
1000 allot
( free 500 cells )
-500 allot

View file

@ -0,0 +1 @@
newstring = "This is creating and saving" " a new single string " "starting with three separate strings."

View file

@ -0,0 +1 @@
newarray = array(100)

View file

@ -0,0 +1 @@
newtable = table()

View file

@ -0,0 +1 @@
data("listnode(next,prev,datafield1,datafield2)")

View file

@ -0,0 +1 @@
newnode = listnode(,,"string data value1",17)

View file

@ -0,0 +1 @@
datafield1(newnode) = "updated data value 1"

View file

@ -0,0 +1 @@
newnode =

View file

@ -0,0 +1 @@
collect()

View file

@ -0,0 +1,5 @@
int Array(10); \allocates 10 integers (40 bytes) of heap space
Array2:= Reserve(10*4); \another way to allocate 10 integers of heap space
Array3:= MAlloc(4); \allocate 4 paragraphs (64 bytes) of conventional memory
...
Release(Array3); \release this memory so it can be used elsewhere

View file

@ -0,0 +1,3 @@
10 REM This code is written for a 48k spectrum
20 CLEAR 65535 - 8192: REM reserve 8192 bytes of memory
30 CLEAR 65535: REM unreserve the memory, moving the ramtop back to the top of the ram