File: vararg-constants.sml

package info (click to toggle)
mlton 20210117%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,464 kB
  • sloc: ansic: 27,682; sh: 4,455; asm: 3,569; lisp: 2,879; makefile: 2,347; perl: 1,169; python: 191; pascal: 68; javascript: 7
file content (65 lines) | stat: -rw-r--r-- 1,575 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(* vararg-constants.sml
 *
 * Constants shared between calling coded and the interpreter generator.
 *)

structure VarargConstants =
  struct

    structure W = Word32

  (* encodings for the kinds of argument locations *)
    local
	val [ GPR, FPR, STK, FSTK ] = List.tabulate(4,  W.fromInt)
    in
    fun kind CLocKind.GPR = GPR
      | kind CLocKind.FPR = FPR
      | kind CLocKind.STK = STK
      | kind CLocKind.FSTK = FSTK
    end

  (* 
   * the located argument structure:

      typedef void* Word_t;
      enum loc_kind {GPR=0, FPR, STK, FSTK};
      struct located_arg_s {
	loc_kind k;
	int width;
	int narrowing;
	int loc;
	int offset;
	union {
	   Word_t* p; long l; int i; char* s; double d; 
	} arg;
      };

   * The following offsets should mimic the way that C lays out the struct.
   *)
    val [ kindOffB, widthOffB, narrowingOffB, locOffB, offsetOffB, argOffB ] = 
	                 List.tabulate(6, fn i => W.fromInt i * 0w4)

  (* max byte width of arguments *)
    val maxArgSzB = 8

    val argSzB : W.word = 0w8

  (* number of bytes for a located argument  *)
    val locdArgSzB = argOffB + argSzB

    val varargInterpreter = "VarargInterp"

    val header = String.concatWith "\n" [
          "/* ",
	  " * ",
	  " * This file is GENERATED by the varargs library. Modify the",
	  " * code at your peril :).",
	  " * ",
	  " * This interpreter parses the arguments for a vararg C function,",
	  " * putting them in the correct locations, and then calls the function.",
	  " * ",
	  " * Mike Rainey (mrainey@cs.uchicago.edu)",
	  " */"
	]

  end