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

Method construct

src/ast/ast.cpp:1045–1082  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1043 }
1044
1045 void BuiltInFunction::construct (const vector<TypeDeclPtr> & args ) {
1046 this->totalStackSize = sizeof(Prologue);
1047 for ( size_t argi=1; argi != args.size(); ++argi ) {
1048 auto arg = new Variable();
1049 arg->name = "arg" + to_string(argi-1);
1050 arg->type = args[argi];
1051 if ( arg->type->baseType==Type::fakeContext ) {
1052 arg->init = new ExprFakeContext(at);
1053 arg->init->generated = true;
1054 } else if ( arg->type->baseType==Type::fakeLineInfo ) {
1055 arg->init = new ExprFakeLineInfo(at);
1056 arg->init->generated = true;
1057 }
1058 if ( arg->type->isTempType() ) {
1059 arg->type->implicit = true;
1060 }
1061 this->arguments.push_back(arg);
1062 }
1063 result = args[0];
1064 if ( result->isRefType() && !result->ref ) {
1065 if ( result->canCopy() ) {
1066 copyOnReturn = true;
1067 moveOnReturn = false;
1068 } else if ( result->canMove() ) {
1069 copyOnReturn = false;
1070 moveOnReturn = true;
1071 } else if ( result->ref ) {
1072 // its ref, so its fine
1073 } else if ( result->hasNonTrivialCtor() ) {
1074 // we can initialize it locally
1075 } else {
1076 DAS_FATAL_ERROR("BuiltInFn %s can't be bound. It returns values which can't be copied or moved\n", name.c_str());
1077 }
1078 } else {
1079 copyOnReturn = false;
1080 moveOnReturn = false;
1081 }
1082 }
1083
1084 void BuiltInFunction::constructExternal (const vector<TypeDeclPtr> & args ) {
1085 this->totalStackSize = sizeof(Prologue);

Callers

nothing calls this directly

Calls 9

to_stringFunction · 0.85
isTempTypeMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
isRefTypeMethod · 0.45
canCopyMethod · 0.45
canMoveMethod · 0.45
hasNonTrivialCtorMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected