File: static6.c

package info (click to toggle)
lie 2.2.2%2Bdfsg-4
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 1,036 kB
  • sloc: ansic: 12,761; yacc: 395; makefile: 111; sh: 4
file content (157 lines) | stat: -rw-r--r-- 3,668 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
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
148
149
150
151
152
153
154
155
156
157
#include "lie.h"

static object
int_abs_int(a)
    object	    a;
{
    object	    result;
    result = (object) mkintcel(labs(a->i.intval));
    return (result);
}

static object
int_min_int(a)
    object	    a;
{
    if (isshared(a))
	return (object) mkintcel(-a->i.intval);
    else {
	a->i.intval = -a->i.intval;
	return a;
    }
}

static object
int_lt_int_int(a, b)
    object	    a, b;
{
    boolean crit = (a->i.intval < b->i.intval); 
    freemem(a);freemem(b);
    if (crit)
	return (object) bool_true;
    return (object) bool_false;
}

static object
int_gt_int_int(a, b)
    object	    a, b;
{
    boolean crit = (a->i.intval > b->i.intval); 
    freemem(a);freemem(b);
    if (crit) 
	return (object) bool_true;
    return (object) bool_false;
}

static object
int_le_int_int(a, b)
    object	    a, b;
{
    boolean crit = (a->i.intval <= b->i.intval); 
    freemem(a);freemem(b);
    if (crit) 
	return (object) bool_true;
    return (object) bool_false;
}

static object
int_ge_int_int(a, b)
    object	    a, b;
{
    boolean crit = (a->i.intval >= b->i.intval); 
    freemem(a);freemem(b);
    if (crit) 
	return (object) bool_true;
    return (object) bool_false;
}

static object
int_eq_int_int(a, b)
    object	    a, b;
{
    boolean crit = (a->i.intval == b->i.intval);
    freemem(a);freemem(b);
    if (crit) return (object) bool_true;
    return (object) bool_false;
}
static object
int_ne_int_int(a, b)
    object	    a, b;
{
    boolean crit = (a->i.intval != b->i.intval);
    freemem(a);freemem(b);
    if (crit) return (object) bool_true;
    return (object) bool_false;
}

static object
int_add_int_int(a, b)
    object	    a, b;
{
    object	    result;
    result = (object) mkintcel(a->i.intval + b->i.intval);
    return (result);
}

static object
int_dif_int_int(a, b)
    object	    a, b;
{
    object	    result;
    result = (object) mkintcel(a->i.intval - b->i.intval);
    return (result);
}

static object
int_mul_int_int(a, b)
    object	    a, b;
{
    object	    result;
    result = (object) mkintcel(a->i.intval * b->i.intval);
    return (result);
}

static object int_div_int_int(object a, object b)
{ if (b->i.intval==0) error("Division by zero.\n");
  return (object) mkintcel(a->i.intval / b->i.intval);
}

static object int_mod_int_int(object a, object b)
{ entry x = a->i.intval,n=b->i.intval;
  if (n <= 0) error("Modulus must be positive number.\n");
  return (object) mkintcel(x>=0?x%n:((-x)%n==0?0:n-((-x)%n)));
}

 static object addupdate_int_int(a,b) 
 object a,b ;
 {
     object result;
     if (type_of(a) == BIGINT || isshared(a)) 
	 result = (object) mkintcel(Integer(a)); 
     else result = a;
     result -> i.intval += Integer(b);
     return result;
 }

static object
vid_addupdate_int_int(list)
    symblst	    list;
{return inside_vid_assign(list,true,addupdate_int_int);} 

Symbrec static6[] = {
    C1("abs", int_abs_int, INTEGER, INTEGER)
    C2("==", int_eq_int_int, INTEGER, INTEGER, INTEGER)
    C2("!=", int_ne_int_int, INTEGER, INTEGER, INTEGER)
    C2("<=", int_le_int_int, INTEGER, INTEGER, INTEGER)
    C2(">=", int_ge_int_int, INTEGER, INTEGER, INTEGER)
    C2("<", int_lt_int_int, INTEGER, INTEGER, INTEGER)
    C2(">", int_gt_int_int, INTEGER, INTEGER, INTEGER)
    C1("-", int_min_int, INTEGER, INTEGER)
    C2("+", int_add_int_int, INTEGER, INTEGER, INTEGER)
    C2("-", int_dif_int_int, INTEGER, INTEGER, INTEGER)
    C2("*", int_mul_int_int, INTEGER, INTEGER, INTEGER)
    C2("/", int_div_int_int, INTEGER, INTEGER, INTEGER)
    C2("%", int_mod_int_int, INTEGER, INTEGER, INTEGER)
    M2(".+=",vid_addupdate_int_int, VOID,INTEGER,INTEGER)
};
int nstatic6 = array_size(static6);