- implemented the string concatenation operator '..'. This is capable of stringifying all of the common types for output.
- gave OP_CONCAT some sane semantics. The way this was defined, by specifying the source operands as a range of registers instead of a pair like everything else made it completely useless for the task at hand. - changed formatting for floats to %.5f which for normal output in a game makes more sense. For special cases there should be a special formatting function for ints and floats that can do more specialized conversions.
This commit is contained in:
parent
24481781b4
commit
34c949f84b
7 changed files with 175 additions and 24 deletions
|
|
@ -704,16 +704,7 @@ begin:
|
|||
|
||||
OP(CONCAT):
|
||||
ASSERTS(a); ASSERTS(B); ASSERTS(C);
|
||||
{
|
||||
FString *rB = ®.s[B];
|
||||
FString *rC = ®.s[C];
|
||||
FString concat(*rB);
|
||||
for (++rB; rB <= rC; ++rB)
|
||||
{
|
||||
concat += *rB;
|
||||
}
|
||||
reg.s[a] = concat;
|
||||
}
|
||||
reg.s[a] = reg.s[B] + reg.s[C];
|
||||
NEXTOP;
|
||||
OP(LENS):
|
||||
ASSERTD(a); ASSERTS(B);
|
||||
|
|
@ -1680,8 +1671,16 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
|||
reg.d[a] = (int)(unsigned)reg.f[b];
|
||||
break;
|
||||
case CAST_F2S:
|
||||
ASSERTS(a); ASSERTD(b);
|
||||
reg.s[a].Format("%.14g", reg.f[b]);
|
||||
ASSERTS(a); ASSERTF(b);
|
||||
reg.s[a].Format("%.5f", reg.f[b]); // keep this small. For more precise conversion there should be a conversion function.
|
||||
break;
|
||||
case CAST_V22S:
|
||||
ASSERTS(a); ASSERTF(b+1);
|
||||
reg.s[a].Format("(%.5f, %.5f)", reg.f[b], reg.f[b + 1]);
|
||||
break;
|
||||
case CAST_V32S:
|
||||
ASSERTS(a); ASSERTF(b + 2);
|
||||
reg.s[a].Format("(%.5f, %.5f, %.5f)", reg.f[b], reg.f[b + 1], reg.f[b + 2]);
|
||||
break;
|
||||
|
||||
case CAST_P2S:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue