Skip to content

Commit

Permalink
Edit TypeClass
Browse files Browse the repository at this point in the history
edit make size method so the new size = size of property + 4 * number of method in this class + size of parent class

Add getLabel method to MethodWrapper
  • Loading branch information
Mohammed Ghanem committed May 23, 2016
1 parent a146290 commit 28cd73a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/TypeSystem/TypeClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ TypeExpression* TypeClass::buildClass(ClassDefineNode* classNode, Class* classSy
typeClass->addToMembers(prop);
typeClass->addToProps(prop);
}
//all members added, tell typeClass to resize itself:
typeClass->makeSize();


//extract methods' types and symbols from @classNode and append them to the TypeClass members as a @MethodWrapper
for (auto &method : classNode->classMethodsNodes) {
Expand Down Expand Up @@ -68,6 +67,9 @@ TypeExpression* TypeClass::buildClass(ClassDefineNode* classNode, Class* classSy
//and finally, add it to the TypeClasses we have:
TypeClass::classInstances.push_back(typeClass);

//all members added, tell typeClass to resize itself:
typeClass->makeSize();

return typeClass;
}

Expand Down Expand Up @@ -177,10 +179,16 @@ MethodWrapper* TypeClass::lookupMembers(string memberStr, string methodSign) {

void TypeClass::makeSize() {
int size = 0;

for (auto mem : this->props) {
size += mem->getSize();
}
this->size = size;

for(auto methoed: this->methods){
size += 4;
}
int parentSize = parentClass->getSize();
this->size = size + parentSize;
}

bool TypeClass::equivelantTo(int secondTypeId){
Expand Down Expand Up @@ -252,6 +260,10 @@ string MethodWrapper::getName() {
return this->methodSymbol->getName();
}

string MethodWrapper::getLabel() {
return this->methodSymbol->getLabel();
}

int MethodWrapper::getWrapperType() {
return MemberWrapper::METHOD_WRAPPER;
}
Expand Down
2 changes: 2 additions & 0 deletions src/TypeSystem/TypeClass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class MethodWrapper : public MemberWrapper {
Method* methodSymbol;
public:
MethodWrapper(TypeExpression* type, Method* methodSymbol);

string getLabel();

string getUniqueName();

Expand Down

0 comments on commit 28cd73a

Please sign in to comment.