Subversion Repositories Kolibri OS

Rev

Rev 7567 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7567 Rev 7744
Line 11... Line 11...
11
	dword value = 0;
11
	dword value = 0;
12
	WHILE(count > 0)
12
	WHILE(count > 0)
13
	{
13
	{
14
		name = DSDWORD[args];
14
		name = DSDWORD[args];
15
		args += 4;
15
		IF (DSDWORD[name+4] == TSym) name = DSDWORD[name];
-
 
16
		ELSE 
-
 
17
		{
-
 
18
			con_printf stdcall ("Error variable!");
-
 
19
			ExitProcess();
-
 
20
		}
-
 
21
		args += 4;
16
		value = DSDWORD[args];
22
		value = DSDWORD[args];
17
		args += 4;
23
		args += 4;
18
		variables.set(name, value);
24
		variables.set(name, value);
19
		count -= 2;
25
		count -= 2;
20
	}
26
	}
21
}
27
}
22
 
28
 
Line 23... Line 29...
23
:dword std_get(dword count, args)
29
:dword std_get(dword count, args)
24
{
30
{
-
 
31
	dword name = 0;
25
	IF(!count) RETURN 0;
32
	IF(!count) RETURN 0;
-
 
33
	name = DSDWORD[args];
-
 
34
	IF (DSDWORD[name+4] != TSym)
-
 
35
	{
-
 
36
		con_printf stdcall ("Error variable!");
-
 
37
		ExitProcess();
-
 
38
	}
26
	RETURN variables.get(DSDWORD[args]);
39
	RETURN variables.get(DSDWORD[name]);
27
}
40
}
Line 28... Line 41...
28
 
41
 
29
:dword std_str(dword count, args)
42
:dword std_str(dword count, args)
30
{
43
{
Line 69... Line 82...
69
/* Console functions */
82
/* Console functions */
70
:dword std_print(dword count, args)
83
:dword std_print(dword count, args)
71
{
84
{
72
	dword ret = 0;
85
	dword ret = 0;
-
 
86
	dword arg = 0;
-
 
87
	dword val = 0;
73
	consoleInit();
88
	consoleInit();
-
 
89
	IF (!count) con_printf stdcall ("nil");
74
	WHILE(count)
90
	WHILE(count)
75
	{
91
	{
-
 
92
		arg = DSDWORD[args];
-
 
93
		REPEAT1:
-
 
94
		IF (DSDWORD[arg+4] == TInt) val = itoa(DSDWORD[arg]);
-
 
95
		ELSE IF (DSDWORD[arg+4] == TStr) val = DSDWORD[arg];
-
 
96
		ELSE IF (DSDWORD[arg+4] == TSym) 
-
 
97
		{
-
 
98
			arg = std_get(1, args);
-
 
99
			goto REPEAT1;
-
 
100
		}
76
		IF(!DSDWORD[args]) con_printf stdcall ("nil");
101
		IF(!arg) con_printf stdcall ("nil");
77
		ELSE con_printf stdcall (DSDWORD[args]);
102
		ELSE con_printf stdcall (val);
78
		args+=4;
103
		args+=4;
79
		count--;
104
		count--;
80
	}
105
	}
81
	RETURN ret;
106
	RETURN ret;
82
}
107
}
Line 83... Line 108...
83
 
108
 
84
:dword std_input(dword count, args)
109
:dword std_len(dword count, args)
-
 
110
{
85
{
111
	dword ret = 0;
86
	dword buf = 0;
112
	dword arg = 0;
87
	consoleInit();
113
	dword val = 0;
-
 
114
	ret = malloc(TLen);
-
 
115
	DSDWORD[ret] = 0;
88
	buf = malloc(100);
116
	DSDWORD[ret+4] = TInt;
89
	WHILE(count)
117
	WHILE(count)
-
 
118
	{
-
 
119
		arg = DSDWORD[args];
-
 
120
		REPEAT1:
-
 
121
		IF (DSDWORD[arg+4] == TStr) val = DSDWORD[arg];
-
 
122
		ELSE IF (DSDWORD[arg+4] == TSym) 
-
 
123
		{
-
 
124
			arg = std_get(1, args);
-
 
125
			goto REPEAT1;
-
 
126
		}
90
	{
127
		ELSE return ret;
91
		con_printf stdcall (DSDWORD[args]);
128
		DSDWORD[ret] += DSDWORD[arg+8];
92
		args+=4;
129
		args+=4;
93
		count--;
130
		count--;
-
 
131
	}
-
 
132
	RETURN ret;
-
 
133
}
-
 
134
 
-
 
135
:dword std_cmp(dword count, args)
-
 
136
{
-
 
137
	dword ret = 0;
-
 
138
	dword arg = 0;
-
 
139
	dword val = 0;
-
 
140
	dword tmp = 0;
-
 
141
	dword x = 0;
-
 
142
	dword y = 0;
-
 
143
	byte start = 0;
-
 
144
	ret = malloc(TLen);
-
 
145
	DSDWORD[ret] = 0;
-
 
146
	DSDWORD[ret+4] = TInt;
-
 
147
	IF (!count) return ret;
-
 
148
	while(count)
-
 
149
	{
-
 
150
		arg = DSDWORD[args];
-
 
151
		REPEAT2:
-
 
152
		IF (DSDWORD[arg+4] == TSym) 
-
 
153
		{
-
 
154
			arg = std_get(1, args);
-
 
155
			goto REPEAT2;
-
 
156
		}
-
 
157
		IF (!start)
-
 
158
		{
-
 
159
			start = 1;
-
 
160
			tmp = arg;
-
 
161
			args+=4;
-
 
162
			count--;
-
 
163
			continue;
-
 
164
		}
-
 
165
		IF (DSDWORD[tmp+4] != DSDWORD[arg+4]) return ret;
-
 
166
		IF (DSDWORD[tmp+4] == TInt)
-
 
167
		{
-
 
168
			IF (DSDWORD[tmp] != DSDWORD[arg]) return ret;
-
 
169
		}
-
 
170
		ELSE IF (DSDWORD[tmp+4] == TStr)
-
 
171
		{
-
 
172
			/*IF (!DSDWORD[tmp+8]) DSDWORD[tmp+8] = crc32(DSDWORD[tmp]);
-
 
173
			IF (!DSDWORD[arg+8]) DSDWORD[arg+8] = crc32(DSDWORD[arg]);
-
 
174
			IF (DSDWORD[tmp+8] != DSDWORD[arg+8]) return ret;*/
-
 
175
			IF (strcmp(DSDWORD[tmp], DSDWORD[arg])) return ret;
-
 
176
		}
-
 
177
		args+=4;
-
 
178
		count--;
-
 
179
	}
-
 
180
	DSDWORD[ret] = 1;
-
 
181
	return ret;
-
 
182
}
-
 
183
 
-
 
184
:dword std_input(dword count, args)
-
 
185
{
-
 
186
	dword buf = 0;
-
 
187
	consoleInit();
-
 
188
	buf = malloc(100);
94
	}
189
	IF (count) std_print(count, args);
-
 
190
	con_gets stdcall(buf, 100);
-
 
191
	EDX = malloc(TLen);
-
 
192
	DSDWORD[EDX] = buf;
95
	con_gets stdcall(buf, 100);
193
	DSDWORD[EDX+4] = TStr;
96
	RETURN EAX;
194
	RETURN EDX;
Line 97... Line 195...
97
}
195
}
98
 
196
 
99
void Init()
197
void Init()
Line 105... Line 203...
105
	functions.set("input", #std_input);
203
	functions.set("input", #std_input);
106
	
204
	
Line 107... Line 205...
107
	/* String functions */
205
	/* String functions */
108
	functions.set("str", #std_str);
206
	functions.set("str", #std_str);
-
 
207
	functions.set("len", #std_len);
Line 109... Line 208...
109
	
208
	
110
	/* System functions */
209
	/* System functions */
Line 111... Line 210...
111
	functions.set("exit", #std_exit);
210
	functions.set("exit", #std_exit);
112
	
211
	
113
	/* Math functions */
212
	/* Math functions */
-
 
213
	functions.set("+", #std_add);
Line 114... Line 214...
114
	functions.set("+", #std_add);
214
	functions.set("-", #std_sub);
115
	functions.set("-", #std_sub);
215
	functions.set("==", #std_cmp);
116
	
216