DEADSOFTWARE

Теперь возможен вызов процедур-переменных из полей записей
[dsw-obn.git] / src / test.c
index 9fad93d4461223fcc752d5a79e48261711e9709d..3305807bbb3fa1c87b0cbd508aaec7e6787ebbfb 100644 (file)
@@ -8,26 +8,39 @@ static char source_test[] =
        "(* Main module *)"
        "MODULE Test;"
        "IMPORT Out;"
+       "TYPE"
+       "  Callback = PROCEDURE;"
+       "  Callfront = PROCEDURE(x : LONGINT) : LONGINT;"
+       "  RecDesc = RECORD"
+       "    cb : Callback;"
+       "    cf : Callfront;"
+       "  END;"
        ""
        "VAR"
-       "  byte     : BYTE;"
-       "  short    : SHORTINT;"
-       "  int      : INTEGER;"
-       "  long     : LONGINT;"
-       "  real     : REAL;"
-       "  longreal : LONGREAL;"
+       "  r : RecDesc;"
+       "  i : LONGINT;"
+       ""
+       "PROCEDURE Stuff;"
+       "BEGIN"
+       "  Out.Int(0123456789, 0); Out.Ln;"
+       "END Stuff;"
+       ""
+       "PROCEDURE Ffuts (x : LONGINT) : LONGINT;"
+       "BEGIN"
+       "  RETURN 9876543210 + x;"
+       "END Ffuts;"
        ""
        "BEGIN"
        "  Out.Open;"
-       "  byte := 127;"
-       "  int := 666 DIV 2;"
-       "  long := int;"
-       "  real := (4 / 1) - (4 / 3) + (4 / 5) - (4 / 7) + (4 / 9) - (4 / 11) + (4 / 13) - (4 / 15) + (4 / 17);"
-       "  longreal := (4 / 1) - (4 / 3) + (4 / 5) - (4 / 7) + (4 / 9) - (4 / 11) + (4 / 13) - (4 / 15) + (4 / 17);"
-       "  Out.Int(666, 0); Out.Ln;"
-       "  Out.Int(byte, 0); Out.Ln;"
-       "  Out.Real(real, 0); Out.Ln;"
-       "  Out.LongReal(longreal, 0); Out.Ln;"
+       "  Out.Int(1, 0); Out.Ln;"
+       "  r.cb := Stuff;"
+       "  Out.Int(2, 0); Out.Ln;"
+       "  r.cb();"
+       "  Out.Int(3, 0); Out.Ln;"
+       "  r.cf := Ffuts;"
+       "  Out.Int(4, 0); Out.Ln;"
+       "  i := r.cf(0123456789);"
+       "  Out.Int(i, 0); Out.Ln;"
        "END Test."
 ;