File: gen.c

package info (click to toggle)
klic 3.003-1.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,068 kB
  • ctags: 6,333
  • sloc: ansic: 101,584; makefile: 3,395; sh: 1,321; perl: 312; exp: 131; tcl: 111; asm: 102; lisp: 4; sed: 1
file content (147 lines) | stat: -rw-r--r-- 3,153 bytes parent folder | download | duplicates (2)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* Compiled by KLIC compiler version 3.003 (Sun Mar 21 15:27:19 JST 1999) */
#include <klic/klichdr.h>
#include "atom.h"
#include "funct.h"
#include <klic/gobj.h>
#include <klic/g_pointer.h>
#include <klic/g_termarray.h>
typedef q * (*gd_func)();

module module_generic();
Const struct predicate predicate_generic_xnew_3 =
   { module_generic, 0, 3 };
Const struct predicate predicate_generic_xgeneric_2 =
   { module_generic, 1, 2 };

module module_generic(glbl, qp, allocp, toppred)
  struct global_variables *glbl;
  struct goalrec *qp;
  register q *allocp;
  Const struct predicate *toppred;
{
  q a0, a1, a2;

  q *reasonp;
 module_top:
  a0 = qp->args[0];
  a1 = qp->args[1];
  switch_on_pred() {
    case_pred(0, new_3_top);
    last_case_pred(1, generic_2_top);
  }

 new_3_top: {
  q x0;
  a2 = qp->args[2];
  qp = qp->next;
 new_3_clear_reason:
  reasonp = reasons;
 new_3_0:
 new_3_1:
  switch (ptagof(a1)) {
 case FUNCTOR:
 new_3_2:
 new_3_3:
  switch (ptagof(a2)) {
 case FUNCTOR:
 new_3_4:
  
{
  unsigned long argc;
  q *argv;
  gd_func func = (gd_func)(((struct pointer_object *)
                           (data_objectp(a1)))->pointer);
  argc = ((struct termarray_object *)(data_objectp(a2)))->nterm;
  argv = ((struct termarray_object *)(data_objectp(a2)))->terms;
  x0   = (q)func(argc,argv,allocp);
  allocp = heapp;
}
  unify(x0, a0);
  proceed();
 case VARREF:
  deref_and_jump(a2,new_3_3);
  *reasonp++ =  a2;
  goto new_3_interrupt;
  };
  goto new_3_interrupt;
 case VARREF:
  deref_and_jump(a1,new_3_1);
  *reasonp++ =  a1;
  goto new_3_interrupt;
  };
  goto new_3_interrupt;
 new_3_ext_interrupt:
  reasonp = 0l;
 new_3_interrupt:
  goto interrupt_3;
 }

 generic_2_top: {
  qp = qp->next;
 generic_2_clear_reason:
  reasonp = reasons;
 generic_2_0:
 generic_2_1:
  switch (ptagof(a0)) {
 case ATOMIC:
  if (isint(a0)) goto generic_2_interrupt;
 generic_2_2:
 generic_2_3:
  switch (ptagof(a1)) {
 case FUNCTOR:
 generic_2_4:
  if (!isgobj(a1)) goto generic_2_interrupt;
 generic_2_5:
  {
  extern unsigned long enter_functor();
  unsigned long funct = enter_functor(symval(a0), 0);
  allocp = gd_generic(allocp, a1, funct, 0);
}
  proceed();
 case VARREF:
  deref_and_jump(a1,generic_2_3);
  *reasonp++ =  a1;
  goto generic_2_interrupt;
  };
  goto generic_2_interrupt;
 case FUNCTOR:
 generic_2_6:
 generic_2_7:
  switch (ptagof(a1)) {
 case FUNCTOR:
 generic_2_8:
  if (!isgobj(a1)) goto generic_2_interrupt;
 generic_2_9:
  
  allocp = gd_generic(allocp,a1,symval((functorp(a0))->functor),
                     &((functorp(a0))->args[0]));

  proceed();
 case VARREF:
  deref_and_jump(a1,generic_2_7);
  *reasonp++ =  a1;
  goto generic_2_interrupt;
  };
  goto generic_2_interrupt;
 case VARREF:
  deref_and_jump(a0,generic_2_1);
  *reasonp++ =  a0;
  goto generic_2_interrupt;
  };
  goto generic_2_interrupt;
 generic_2_ext_interrupt:
  reasonp = 0l;
 generic_2_interrupt:
  goto interrupt_2;
 }
 interrupt_3:
  allocp[4] = a2;
 interrupt_2:
  allocp[3] = a1;
 interrupt_1:
  allocp[2] = a0;
 interrupt_0:
  allocp = interrupt_goal(allocp, toppred, reasonp);
 proceed_label:
  loop_within_module(module_generic);
}