aboutsummaryrefslogtreecommitdiff
path: root/compiler/elymasGlobalSysTyped.ey
blob: bdc88d079176a61e5d6daa1caf3886907b332d0c (plain)
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
66
67
68
69
70
71
72
73
74
<
  <
    # return the array of input types of a function
    # 0 -> the function object to analyze
    # 0 <- the array of input types
    [[
      /rbx :popqReg

      /rdx :popqReg
      16 /rdx /rdx :movqMemDisp8Reg
      /rdx /rdx :testqRegReg
      /typed :jnzLbl8

      # untyped functions, it does not officially take any arguments
      /rdi /rdi :xorqRegReg
      ::internalAllocateArray /rax :movqImmReg
      /rax :callqReg
      /rax :pushqReg
      /rbx :pushqReg
      :retn

      @typed
      8 /rdx /rdi :movqMemDisp8Reg
      3 /rdi :shlqImm8Reg
      16 /rdx /rsi :leaqMemDisp8Reg
      /rsi :pushqReg
      ::internalAllocateArray /rax :movqImmReg
      /rax :callqReg

      /rsi :popqReg
      /rax :pushqReg

      8 /rax /rdi :leaqMemDisp8Reg
      /rax /ecx :movlMemReg
      8 /rcx :subqImm8Reg
      :reprcx :movsb

      /rbx :pushqReg
      :retn
    ]] /eyinputs defv

    # return the type of an object
    # 0 -> the object to analyze
    # 0 <- an integer from 0 - 15
    [[
      /rbx :popqReg

      16 /rdi :movqImmReg
      ::internalAllocate /rax :movqImmReg
      /rax :callqReg

      /rdx :popqReg
      7 /rdx /rdx :movzxMem8Disp8Reg64
      4 /rdx :shrqImm8Reg
      /rdx 8 /rax :movqRegMemDisp8

      /rax :pushqReg

      /rbx :pushqReg
      :retn
    ]] /eytype defv
  > _ ==globalFunctions { defv }' ::allocateOffsetStruct

  "typed" enterSubScope

  [
    globalFunctions keys eydeff { | }' createScopeEntries
    createScopeExtensionEntries
  ] :execute

  leaveSubScope
> --

# vim: syn=elymas