generate accessors for array fields

This commit is contained in:
Joshua Warner 2014-06-02 10:31:57 -06:00
parent b5699cc9dc
commit 43bd838c86
4 changed files with 31 additions and 11 deletions

View File

@ -282,7 +282,10 @@ makeStackTraceElement(Thread* t, object e)
{
PROTECT(t, e);
object class_name = className(t, methodClass(t, traceElementMethod(t, e)));
GcMethod* method = cast<GcMethod>(t, traceElementMethod(t, e));
PROTECT(t, method);
object class_name = className(t, method->class_());
PROTECT(t, class_name);
THREAD_RUNTIME_ARRAY(t, char, s, byteArrayLength(t, class_name));
@ -290,20 +293,20 @@ makeStackTraceElement(Thread* t, object e)
reinterpret_cast<char*>(&byteArrayBody(t, class_name, 0)));
class_name = makeString(t, "%s", RUNTIME_ARRAY_BODY(s));
object method = methodName(t, traceElementMethod(t, e));
PROTECT(t, method);
object method_name = method->name();
PROTECT(t, method_name);
method = t->m->classpath->makeString
(t, method, 0, byteArrayLength(t, method) - 1);
method_name = t->m->classpath->makeString
(t, method_name, 0, byteArrayLength(t, method_name) - 1);
unsigned line = t->m->processor->lineNumber
(t, cast<GcMethod>(t, traceElementMethod(t, e)), traceElementIp(t, e));
(t, method, traceElementIp(t, e));
object file = classSourceFile(t, methodClass(t, traceElementMethod(t, e)));
object file = classSourceFile(t, method->class_());
file = file ? t->m->classpath->makeString
(t, file, 0, byteArrayLength(t, file) - 1) : 0;
return reinterpret_cast<object>(makeStackTraceElement(t, class_name, method, file, line));
return reinterpret_cast<object>(makeStackTraceElement(t, class_name, method_name, file, line));
}
object

View File

@ -16,6 +16,7 @@
#include <avian/system/system.h>
#include <avian/system/signal.h>
#include <avian/heap/heap.h>
#include <avian/util/slice.h>
#include "avian/finder.h"
#include "avian/processor.h"
#include "avian/constants.h"

View File

@ -27,15 +27,15 @@ search(Thread* t, object loader, object name,
PROTECT(t, loader);
PROTECT(t, name);
object n = reinterpret_cast<object>(makeByteArray(t, stringLength(t, name) + 1));
char* s = reinterpret_cast<char*>(&byteArrayBody(t, n, 0));
GcByteArray* n = makeByteArray(t, stringLength(t, name) + 1);
char* s = reinterpret_cast<char*>(n->body().begin());
stringChars(t, name, s);
if (replaceDots) {
replace('.', '/', s);
}
return reinterpret_cast<int64_t>(op(t, loader, n));
return reinterpret_cast<int64_t>(op(t, loader, reinterpret_cast<object>(n)));
} else {
throwNew(t, GcNullPointerException::Type);
}

View File

@ -1493,6 +1493,22 @@ void writeClassAccessors(Output* out, Object* t)
out->write(capitalize(memberName(m)));
out->write("); }\n");
} break;
case Object::Array: {
out->write(" avian::util::Slice<");
out->write(memberTypeName(m));
out->write("> ");
out->write(obfuscate(memberName(m)));
out->write("() { return avian::util::Slice<");
out->write(memberTypeName(m));
out->write("> (&field_at<");
out->write(memberTypeName(m));
out->write(">(");
out->write(capitalize(local::typeName(memberOwner(m))));
out->write(capitalize(memberName(m)));
out->write("), field_at<uintptr_t>(");
out->write(capitalize(local::typeName(memberOwner(m))));
out->write("Length)); }\n");
} break;
default:
break;