Compile string concatenations (BC_CAT).

This commit is contained in:
Mike Pall
2013-04-21 01:01:33 +02:00
parent 7b629b7bcf
commit 5f1781a127
18 changed files with 279 additions and 16 deletions

View File

@@ -12,6 +12,7 @@
#include "lj_gc.h"
#include "lj_err.h"
#include "lj_buf.h"
#include "lj_str.h"
LJ_NOINLINE void LJ_FASTCALL lj_buf_grow(SBuf *sb, char *en)
{
@@ -64,6 +65,34 @@ void lj_buf_putmem(SBuf *sb, const void *q, MSize len)
setsbufP(sb, p);
}
#if LJ_HASJIT
SBuf * LJ_FASTCALL lj_buf_putstr(SBuf *sb, GCstr *s)
{
MSize len = s->len;
char *p = lj_buf_more(sb, len);
p = lj_buf_wmem(p, strdata(s), len);
setsbufP(sb, p);
return sb;
}
SBuf * LJ_FASTCALL lj_buf_putint(SBuf *sb, int32_t k)
{
setsbufP(sb, lj_str_bufint(lj_buf_more(sb, LJ_STR_INTBUF), k));
return sb;
}
SBuf * LJ_FASTCALL lj_buf_putnum(SBuf *sb, cTValue *o)
{
setsbufP(sb, lj_str_bufnum(lj_buf_more(sb, LJ_STR_NUMBUF), o));
return sb;
}
GCstr * LJ_FASTCALL lj_buf_tostr(SBuf *sb)
{
return lj_str_new(sbufL(sb), sbufB(sb), sbuflen(sb));
}
#endif
uint32_t LJ_FASTCALL lj_buf_ruleb128(const char **pp)
{
const uint8_t *p = (const uint8_t *)*pp;