996
|
1 /*
|
|
2 * Copyright (c) 2005 Gregor Richards
|
|
3 *
|
|
4 * This file is part of Glass.
|
|
5 *
|
|
6 * Glass is free software; you can redistribute it and/or modify
|
|
7 * it under the terms of the GNU General Public License as published by
|
|
8 * the Free Software Foundation; either version 2 of the License, or
|
|
9 * (at your option) any later version.
|
|
10 *
|
|
11 * Glass is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 * GNU General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with Glass; if not, write to the Free Software
|
|
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 */
|
|
20
|
|
21 #include "variable.h"
|
|
22
|
|
23 void Variable::init()
|
|
24 {
|
|
25 type = VAR_NUMBER;
|
|
26 nval = 0.0;
|
|
27 sval = "";
|
|
28 kval = NULL;
|
|
29 kival = NULL;
|
|
30 fval = NULL;
|
|
31 }
|
|
32
|
|
33 Variable::Variable() { init(); }
|
|
34
|
|
35 Variable::Variable(int stype, double val)
|
|
36 {
|
|
37 init();
|
|
38 if (stype == VAR_NUMBER) {
|
|
39 nval = val;
|
|
40 }
|
|
41 }
|
|
42
|
|
43 Variable::Variable(int stype, string val)
|
|
44 {
|
|
45 init();
|
|
46 if (stype == VAR_VARIABLEP ||
|
|
47 stype == VAR_STRING) {
|
|
48 type = stype;
|
|
49 sval = val;
|
|
50 }
|
|
51 }
|
|
52
|
|
53 Variable::Variable(int stype, void *val)
|
|
54 {
|
|
55 init();
|
|
56 if (stype == VAR_KLASS) {
|
|
57 type = stype;
|
|
58 kval = (Klass *) val;
|
|
59 } else if (stype == VAR_KLASSI) {
|
|
60 type = stype;
|
|
61 kival = (KlassI *) val;
|
|
62 } else if (stype == VAR_FUNC) {
|
|
63 type = stype;
|
|
64 fval = (Func *) val;
|
|
65 }
|
|
66 }
|
|
67
|
|
68 Variable::Variable(int stype, void *vala, void *valb)
|
|
69 {
|
|
70 init();
|
|
71 if (stype == VAR_FUNCI) {
|
|
72 type = stype;
|
|
73 kival = (KlassI *) vala;
|
|
74 fval = (Func *) valb;
|
|
75 }
|
|
76 }
|
|
77
|
|
78 Variable::Variable(Variable ©)
|
|
79 {
|
|
80 mkcopy(copy);
|
|
81 }
|
|
82
|
|
83 void Variable::mkcopy(Variable ©)
|
|
84 {
|
|
85 type = copy.type;
|
|
86 nval = copy.nval;
|
|
87 sval = copy.sval;
|
|
88 kval = copy.kval;
|
|
89 kival = copy.kival;
|
|
90 fval = copy.fval;
|
|
91 }
|