| 1082 | } |
| 1083 | |
| 1084 | void BuiltInFunction::constructExternal (const vector<TypeDeclPtr> & args ) { |
| 1085 | this->totalStackSize = sizeof(Prologue); |
| 1086 | for ( size_t argi=1; argi != args.size(); ++argi ) { |
| 1087 | auto arg = new Variable(); |
| 1088 | arg->name = "arg" + to_string(argi-1); |
| 1089 | arg->type = args[argi]; |
| 1090 | if ( arg->type->baseType==Type::fakeContext ) { |
| 1091 | arg->init = new ExprFakeContext(at); |
| 1092 | arg->init->generated = true; |
| 1093 | } else if ( arg->type->baseType==Type::fakeLineInfo ) { |
| 1094 | arg->init = new ExprFakeLineInfo(at); |
| 1095 | arg->init->generated = true; |
| 1096 | } |
| 1097 | this->arguments.push_back(arg); |
| 1098 | } |
| 1099 | result = args[0]; |
| 1100 | if ( result->isRefType() && !result->ref ) { |
| 1101 | if ( result->canCopy() ) { |
| 1102 | copyOnReturn = true; |
| 1103 | moveOnReturn = false; |
| 1104 | } else if ( result->canMove() ) { |
| 1105 | copyOnReturn = false; |
| 1106 | moveOnReturn = true; |
| 1107 | } else if ( !result->ref ) { |
| 1108 | DAS_FATAL_ERROR("ExternalFn %s can't be bound. It returns values which can't be copied or moved\n", name.c_str()); |
| 1109 | } |
| 1110 | } else { |
| 1111 | copyOnReturn = false; |
| 1112 | moveOnReturn = false; |
| 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | void BuiltInFunction::constructInterop (const vector<TypeDeclPtr> & args ) { |
| 1117 | this->totalStackSize = sizeof(Prologue); |