comparison cbackend.js @ 340:7279e21dad68

Fix internal variable name generation for certain float values
author Michael Pavone <pavone@retrodev.com>
date Sun, 05 Apr 2015 21:34:49 -0700
parents 2a0463c46913
children 06dceff348ea
comparison
equal deleted inserted replaced
339:74cab9b5f2a4 340:7279e21dad68
163 return [ (needsreturn ? 'return (object *)' : '' ) + this.toCLLExpr(vars) + ';' ]; 163 return [ (needsreturn ? 'return (object *)' : '' ) + this.toCLLExpr(vars) + ';' ];
164 }; 164 };
165 165
166 floatlit.prototype.toC = function() { 166 floatlit.prototype.toC = function() {
167 var floatType = this.bits == 32 ? 'float' : 'double'; 167 var floatType = this.bits == 32 ? 'float' : 'double';
168 var str = floatType + '_' + (this.val < 0 ? 'neg_' + (0-this.val).toString() : this.val.toString()).replace('.', '_'); 168 var str = floatType + '_' + (this.val < 0 ? 'neg_' + (0-this.val).toString() : this.val.toString()).replace('.', '_').replace('-', 'neg');
169 if (!(str in declaredInts)) { 169 if (!(str in declaredInts)) {
170 toplevelcode += 'obj_float' + this.bits + ' ' + str + ' = {{&obj_float' + this.bits + '_meta, NULL}, ' + this.val.toString() + '};\n'; 170 toplevelcode += 'obj_float' + this.bits + ' ' + str + ' = {{&obj_float' + this.bits + '_meta, NULL}, ' + this.val.toString() + '};\n';
171 declaredInts[str] = true; 171 declaredInts[str] = true;
172 } 172 }
173 return '((object *)&' + str + ')'; 173 return '((object *)&' + str + ')';