annotate src/expr.c @ 14:b28d7cb60779

checkpoint
author lost
date Thu, 23 Oct 2008 02:44:07 +0000
parents 05d4115b4860
children 1f598d89b9b0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
1 /*
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
2 expr.c
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
3 Copyright © 2008 William Astle
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
4
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
5 This file is part of LWASM.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
6
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
10 version.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
11
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
15 more details.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
16
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
19 */
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
20
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
21 /*
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
22 This file contains implementations associated with the expression evaluator
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
23 used by LWASM.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
24
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
25 */
14
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
26
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
27 #include <malloc.h>
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
28
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
29 #define __expr_c_seen__
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
30 #include "expr.h"
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
31
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
32 LWVAL *lwval_construct_int(int value)
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
33 {
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
34 LWVAL *v;
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
35
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
36 v = malloc(sizeof(LWVAL));
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
37 if (!v)
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
38 return NULL;
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
39
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
40 v -> lwval_type = LWVAL_TYPE_INT;
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
41 v -> dt.lwval_int = value;
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
42
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
43 return v;
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
44 }
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
45
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
46 void lwval_destroy(LWVAL *value)
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
47 {
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
48 if (value)
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
49 free(value);
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
50 }
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
51
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
52 // v1 + v2 -> v3, return v3
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
53 LWVAL *lwval_add(LWVAL *v1, LWVAL *v2, LWVAL *v3)
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
54 {
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
55 }
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
56
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
57 // v1 - v2 -> v3, return v3
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
58 LWVAL *lwval_sub(LWVAL *v1, LWVAL *v2, LWVAL *v3)
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
59 {
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
60 }
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
61
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
62 // v1 * v2 -> v3, return v3
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
63 LWVAL *lwval_mul(LWVAL *v1, LWVAL *v2, LWVAL *v3)
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
64 {
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
65 }
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
66
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
67 // v1 / v2 -> v3, return v3
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
68 LWVAL *lwval_div(LWVAL *v1, LWVAL *v2, LWVAL *v3)
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
69 {
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
70 }
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
71
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
72 // v1 % v2 -> v3, return v3
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
73 LWVAL *lwval_mod(LWVAL *v1, LWVAL *v2, LWVAL *v3)
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
74 {
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
75 }