mkdemo.red 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. % Create demobyte.h out of opcodes.red
  2. symbolic;
  3. if not boundp 'demo_key or
  4. not stringp demo_key then <<
  5. fluid '(demo_key);
  6. % The following line looks WIERD but its purpose is to delay this job for
  7. % a while and cause lots of garbage collections (typically a couple of dozen,
  8. % taking around 30 seconds on my reference computer). This gives time for
  9. % the random number generator in CSL to seed itself a bit better. The user
  10. % might like to run other applications, move the CSL window and otherwise
  11. % generate events while this is going on! As an alternative the user can
  12. % provide an explicit initial key via -Ddemo_key=nnn+mmm and take full
  13. % personal responsibility.
  14. for i := 1:10000000 do cons(nil, nil);
  15. demo_key := list!-to!-string
  16. append(explodec random!-fixnum(), '!+ . explodec random!-fixnum()) >>$
  17. demo_key := compress('!( . append(explodec demo_key, '(!))));
  18. demo_key := car demo_key . cadr demo_key$
  19. global '(s!:opcodelist);
  20. off lower;
  21. in "../cslbase/opcodes.red"$
  22. on lower;
  23. begin
  24. scalar o, oo, n;
  25. o := open("../cslbase/demobyte.h", 'output);
  26. oo := wrs o;
  27. printc "/* demobyte.h Copyright (C) Codemist 1999 */";
  28. terpri();
  29. printc "/* Signature: 38cd8141 31-Mar-1993 */";
  30. terpri();
  31. printc "/*";
  32. printc " * Bytecode interpreter support.";
  33. printc " *";
  34. printc " * March 1999";
  35. printc " * Confidential file: do not distribute EVER";
  36. printc " */";
  37. terpri();
  38. princ "int32 demo_key1 = "; prin car demo_key;
  39. princ ", demo_key2 = "; princ cdr demo_key; printc ";";
  40. terpri();
  41. n := 0;
  42. for each v in s!:opcodelist do <<
  43. princ "#define OP_";
  44. princ v;
  45. ttab 32;
  46. princ "0x";
  47. if n < 16 then princ "0";
  48. prinhex n;
  49. terpri();
  50. n := n + 1 >>;
  51. terpri();
  52. printc "/* end of demobyte.h */";
  53. terpri();
  54. wrs oo;
  55. close o;
  56. return "demobyte.h made"
  57. end;
  58. bye;