Add Lua math functions log10 and l2magnitude (nonstandard)
[jpcrr.git] / mnj / lua / Expdesc.java
blobfd89003ac8f1419c27fa5cd75c11e87ef65a732c
1 /* $Header: //info.ravenbrook.com/project/jili/version/1.1/code/mnj/lua/Expdesc.java#1 $
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
3 * All rights reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject
11 * to the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 package mnj.lua;
27 /** Equivalent to struct expdesc. */
28 final class Expdesc
31 static final int VVOID = 0; // no value
32 static final int VNIL = 1;
33 static final int VTRUE = 2;
34 static final int VFALSE = 3;
35 static final int VK = 4; // info = index into 'k'
36 static final int VKNUM = 5; // nval = numerical value
37 static final int VLOCAL = 6; // info = local register
38 static final int VUPVAL = 7; // info = index into 'upvalues'
39 static final int VGLOBAL = 8; // info = index of table;
40 // aux = index of global name in 'k'
41 static final int VINDEXED = 9; // info = table register
42 // aux = index register (or 'k')
43 static final int VJMP = 10; // info = instruction pc
44 static final int VRELOCABLE = 11; // info = instruction pc
45 static final int VNONRELOC = 12; // info = result register
46 static final int VCALL = 13; // info = instruction pc
47 static final int VVARARG = 14; // info = instruction pc
49 int k; // one of V* enums above
50 int info;
51 int aux;
52 double nval;
53 int t;
54 int f;
56 Expdesc()
60 Expdesc(int k, int i)
62 init(k, i);
65 /** Equivalent to init_exp from lparser.c */
66 void init(int kind, int i)
68 this.t = FuncState.NO_JUMP;
69 this.f = FuncState.NO_JUMP;
70 this.k = kind;
71 this.info = i;
74 void init(Expdesc e)
76 // Must initialise all members of this.
77 this.k = e.k;
78 this.info = e.info;
79 this.aux = e.aux;
80 this.nval = e.nval;
81 this.t = e.t;
82 this.f = e.f;
85 int kind()
87 return k;
90 void setKind(int kind)
92 this.k = kind;
95 int info()
97 return info;
100 void setInfo(int i)
102 this.info = i;
105 int aux()
107 return aux;
110 double nval()
112 return nval;
115 void setNval(double d)
117 this.nval = d;
120 /** Equivalent to hasmultret from lparser.c */
121 boolean hasmultret()
123 return k == VCALL || k == VVARARG;
126 /** Equivalent to hasjumps from lcode.c. */
127 boolean hasjumps()
129 return t != f;
132 void nonreloc(int i)
134 k = VNONRELOC;
135 info = i;
138 void reloc(int i)
140 k = VRELOCABLE;
141 info = i;
144 void upval(int i)
146 k = VUPVAL;
147 info = i;