MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / modifyToClassMember

Function modifyToClassMember

src/ast/ast_generate.cpp:2096–2124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2094 }
2095
2096 void modifyToClassMember ( Function * func, Structure * baseClass, bool isExplicit, bool isConstant ) {
2097 // first argument is this
2098 auto argT = new TypeDecl(baseClass);
2099 argT->constant = isConstant;
2100 argT->isExplicit = isExplicit;
2101 auto argV = new Variable();
2102 argV->name = "self";
2103 argV->type = argT;
2104 argV->at = func->at;
2105 argV->generated = true;
2106 argV->capture_as_ref = true;
2107 func->arguments.insert(func->arguments.begin(), argV);
2108 // with self ...
2109 auto block = new ExprBlock();
2110 block->at = func->at;
2111 auto wth = new ExprWith();
2112 wth->at = func->at;
2113 auto wvar = new ExprVar(func->at,"self");
2114 wvar->generated = true;
2115 wth->with = wvar;
2116 wth->body = func->body;
2117 block->list.push_back(wth);
2118 // and done
2119 func->body = block;
2120 func->isClassMethod = true;
2121 func->classParent = baseClass;
2122 DAS_ASSERT(func->classParent);
2123 verifyGenerated(func->body);
2124 }
2125
2126 FunctionPtr makeClassConstructor ( Structure * baseClass, Function * method ) {
2127 // make a function

Callers 1

ast_structVarDefFunction · 0.85

Calls 4

verifyGeneratedFunction · 0.85
insertMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected