1.1 --- a/src/Types.cpp Sat Aug 04 19:33:06 2012 -0700
1.2 +++ b/src/Types.cpp Sat Aug 04 20:12:20 2012 -0700
1.3 @@ -20,6 +20,7 @@
1.4 #include "Types.h"
1.5 #include "Zone.h"
1.6 #include "Strings.h"
1.7 +#include "Structures.h"
1.8 #include "Heap-inl.h"
1.9
1.10 using namespace ke;
1.11 @@ -221,3 +222,20 @@
1.12 return Compare(left->contained(), right->contained());
1.13 }
1.14 }
1.15 +
1.16 +Descriptor *
1.17 +Type::lookupField(Handle<String> name, unsigned *index)
1.18 +{
1.19 + assert(isStruct());
1.20 +
1.21 + for (unsigned i = 0; i < fields_->length(); i++) {
1.22 + Descriptor *desc = Descriptor::cast(fields_->at(i));
1.23 + if (desc->name() == name) {
1.24 + *index = i;
1.25 + return desc;
1.26 + }
1.27 + }
1.28 +
1.29 + return NULL;
1.30 +}
1.31 +