Index: compilers/pct/src/PAST/Compiler.pir =================================================================== --- compilers/pct/src/PAST/Compiler.pir (revision 31421) +++ compilers/pct/src/PAST/Compiler.pir (working copy) @@ -1977,20 +1977,39 @@ returns = $S0 have_returns: - .local string valflags + .local string valflags, valstr $P0 = get_global '%valflags' valflags = $P0[returns] $I0 = index valflags, 'e' - if $I0 < 0 goto escape_done - value = self.'escape'(value) - escape_done: + if $I0 < 0 goto valstr_value + valstr = self.'escape'(value) + goto valstr_done + valstr_value: + ## get the PIR representation of the value + valstr = value + ## IMCC can't handle integer constants outside of + ## -2147483648..2147483647, so if we get one we add a decimal + ## to force IMCC to parse it as a Float. + ## skip over leading minus sign + $S0 = substr valstr, 0, 1 + $I0 = iseq $S0, '-' + ## see if rest of string is all digits, if not, leave valstr alone + $I1 = length valstr + $I0 = find_not_cclass .CCLASS_NUMERIC, valstr, $I0, $I1 + if $I1 != $I0 goto valstr_done + ## it's an integer, now see if value is in -2147483648..2147483647 + if value < -2147483648. goto valstr_float + if value < 2147483648. goto valstr_done + valstr_float: + valstr = concat valstr, '.' + valstr_done: .local string rtype rtype = options['rtype'] $I0 = index valflags, rtype if $I0 < 0 goto result_pmc - ops.'result'(value) + ops.'result'(valstr) .return (ops) result_pmc: @@ -1998,7 +2017,7 @@ result = self.'unique'('$P') returns = self.'escape'(returns) ops.'push_pirop'('new', result, returns) - ops.'push_pirop'('assign', result, value) + ops.'push_pirop'('assign', result, valstr) ops.'result'(result) .return (ops) .end