Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,2 @@
°A→B
.B now contains the address of A

View file

@ -0,0 +1,2 @@
1234→A
1→{A}

View file

@ -0,0 +1,4 @@
........
A%=100
ADDR=VARPTR(A%)
.......

View file

@ -0,0 +1,8 @@
PROGRAM POINTER
BEGIN
A%=100
ADDR=VARPTR(A%)
PRINT(A%) ! prints 100
POKE(ADDR,200)
PRINT(A%) ! prints 200
END PROGRAM

View file

@ -0,0 +1,4 @@
' FB 1.05.0 Win64
Dim a As Integer = 3
Dim p As Integer Ptr = @a
Print a, p

View file

@ -0,0 +1,3 @@
Var p = Cast(Integer Ptr, 1375832)
*p = 42
Print p, *p

View file

@ -0,0 +1,9 @@
include "ConsoleWindow"
dim as short i : i = 575
dim as ptr j : j = NULL
j = @i
print "Adddress of i ="; j
print "Value of i ="; [j]

View file

@ -0,0 +1,4 @@
var x = 12
var xptr = addr(x) # Get address of variable
echo cast[int](xptr) # and print it
xptr = cast[ptr int](0xFFFE) # Set the address

View file

@ -0,0 +1,24 @@
procedure address()
object V
integer addr4 -- stored /4 (assuming dword aligned, which it will be)
#ilASM{
[32]
lea eax,[V]
shr eax,2
mov [addr4],eax
[64]
lea rax,[V]
shr rax,2
mov [addr4],rax
[]
}
if machine_bits()=32 then
poke4(addr4*4,123)
elsif machine_bits()=64 then
poke8(addr4*4,123)
end if
?V
if getc(0) then end if
end procedure
address()

View file

@ -0,0 +1,3 @@
var n = 42;
say Sys.refaddr(\n); # prints the address of the variable
say Sys.refaddr(n); # prints the address of the object at which the variable points to

View file

@ -0,0 +1,31 @@
class MyClass {
}
func printPointer<T>(ptr: UnsafePointer<T>) {
println(ptr)
}
func test() {
var x = 42
var y = 3.14
var z = "foo"
var obj = MyClass()
// Use a pointer to a variable on the stack and print its address
withUnsafePointer(&x) { ptr in println(ptr) }
withUnsafePointer(&y) { ptr in println(ptr) }
withUnsafePointer(&z) { ptr in println(ptr) }
withUnsafePointer(&obj) { ptr in println(ptr) }
// Alternately:
printPointer(&x)
printPointer(&y)
printPointer(&z)
printPointer(&obj)
// Printing the address of an object that an object reference points to
// In Swift 3, unsafeAddress is removed
println(Unmanaged.passUnretained(obj).toOpaque())
}
test()

View file

@ -0,0 +1,2 @@
addr.x
=> 27975840

View file

@ -0,0 +1,2 @@
if (addr.x = addr.y)
..