static Stringp getStackTraceLine(MethodInfo* method, Stringp filename) { AvmCore *core = method->pool()->core; Stringp s = core->newStringLatin1("\tat "); s = core->concatStrings(s, method->format(core)); if (filename) { s = s->appendLatin1("["); s = s->append(filename); s = s->appendLatin1(":"); } return s; }
Stringp ScopeTypeChain::format(AvmCore* core) const { Stringp r = core->kEmptyString; r = r->appendLatin1("STC:["); for (int i = 0; i < fullsize; i++) { if (i > 0) r = r->appendLatin1(","); Traits* t = getScopeTraitsAt(i); bool b = getScopeIsWithAt(i); r = r->append(t->format(core)); r = r->appendLatin1(b?":1":":0"); } r = r->appendLatin1("]"); return r; }
Stringp StringClass::AS3_fromCharCode(Atom *argv, int argc) { AvmCore* core = this->core(); Stringp out = core->kEmptyString; for (int i=0; i<argc; i++) { wchar c = wchar(AvmCore::integer(argv[i])); if (c <= 0xff) { // append16 will always append as k16, forcing the string // to be widened, as String::_append doesn't understand kAuto. // That can/should probably be smarted, but for now, // improve the smarts here: uint8_t c8 = uint8_t(c); out = out->appendLatin1((char*)&c8, 1); } else { // note: this code is allowed to construct a string // containing illegal UTF16 sequences! // (eg, String.fromCharCode(0xD800).charCodeAt(0) -> 0xD800). out = out->append16(&c, 1); } } return out; }
Stringp ScopeChain::format(AvmCore* core) const { Stringp r = core->kEmptyString; r = r->appendLatin1("SC:{dxns=("); r = r->append(_defaultXmlNamespace->format(core)); r = r->appendLatin1("),"); r = r->append(_scopeTraits->format(core)); r = r->appendLatin1(",V:["); for (int i = 0; i < _scopeTraits->size; i++) { if (i > 0) r = r->appendLatin1(","); r = r->append(core->format(_scopes[i])); } r = r->appendLatin1("]}"); return r; }
Stringp StackTrace::format(AvmCore* core) { if(!stringRep) { Stringp s = core->kEmptyString; int displayDepth = depth; if (displayDepth > kMaxDisplayDepth) { displayDepth = kMaxDisplayDepth; } const Element *e = elements; for (int i=0; i<displayDepth; i++, e++) { // env will be NULL if the element is from a fake CallStackNode // omit them since they are only for profiling purposes if (!e->info()) continue; if(i != 0) s = s->appendLatin1("\r\n"); Stringp filename=NULL; if(e->filename()) { StringBuffer sb(core->gc); dumpFilename(e->filename(), sb); filename = core->newStringUTF8(sb.c_str()); } s = core->concatStrings(s, getStackTraceLine(e->info(), filename)); if(e->filename()) { s = core->concatStrings(s, core->intToString(e->linenum())); s = s->appendLatin1("]"); } } stringRep = s; } return stringRep; }