| 8285 | } |
| 8286 | |
| 8287 | int asCCompiler::DoAssignment(asCExprContext *ctx, asCExprContext *lctx, asCExprContext *rctx, asCScriptNode *lexpr, asCScriptNode *rexpr, eTokenType op, asCScriptNode *opNode) |
| 8288 | { |
| 8289 | // Don't allow any operators on expressions that take address of class method |
| 8290 | // If methodName is set but the type is not an object, then it is a global function |
| 8291 | if( lctx->methodName != "" || rctx->IsClassMethod() ) |
| 8292 | { |
| 8293 | Error(TXT_INVALID_OP_ON_METHOD, opNode); |
| 8294 | return -1; |
| 8295 | } |
| 8296 | |
| 8297 | // Implicit handle types should always be treated as handles in assignments |
| 8298 | if (lctx->type.dataType.GetTypeInfo() && (lctx->type.dataType.GetTypeInfo()->flags & asOBJ_IMPLICIT_HANDLE) ) |
| 8299 | { |
| 8300 | lctx->type.dataType.MakeHandle(true); |
| 8301 | lctx->type.isExplicitHandle = true; |
| 8302 | } |
| 8303 | |
| 8304 | // If the left hand expression is a property accessor, then that should be used |
| 8305 | // to do the assignment instead of the ordinary operator. The exception is when |
| 8306 | // the property accessor is for a handle property, and the operation is a value |
| 8307 | // assignment. |
| 8308 | if( (lctx->property_get || lctx->property_set) && |
| 8309 | !(lctx->type.dataType.IsObjectHandle() && !lctx->type.isExplicitHandle) ) |
| 8310 | { |
| 8311 | if( op != ttAssignment ) |
| 8312 | { |
| 8313 | // Generate the code for the compound assignment, i.e. get the value, apply operator, then set the value |
| 8314 | return ProcessPropertyGetSetAccessor(ctx, lctx, rctx, op, opNode); |
| 8315 | } |
| 8316 | |
| 8317 | // It is not allowed to do a handle assignment on a property |
| 8318 | // accessor that doesn't take a handle in the set accessor. |
| 8319 | if( lctx->property_set && lctx->type.isExplicitHandle ) |
| 8320 | { |
| 8321 | // set_opIndex has 2 arguments, where as normal setters have only 1 |
| 8322 | asCArray<asCDataType>& parameterTypes = |
| 8323 | builder->GetFunctionDescription(lctx->property_set)->parameterTypes; |
| 8324 | if( !parameterTypes[parameterTypes.GetLength() - 1].IsObjectHandle() ) |
| 8325 | { |
| 8326 | // Process the property to free the memory |
| 8327 | ProcessPropertySetAccessor(lctx, rctx, opNode); |
| 8328 | |
| 8329 | Error(TXT_HANDLE_ASSIGN_ON_NON_HANDLE_PROP, opNode); |
| 8330 | return -1; |
| 8331 | } |
| 8332 | } |
| 8333 | |
| 8334 | MergeExprBytecodeAndType(ctx, lctx); |
| 8335 | |
| 8336 | return ProcessPropertySetAccessor(ctx, rctx, opNode); |
| 8337 | } |
| 8338 | else if( lctx->property_get && lctx->type.dataType.IsObjectHandle() && !lctx->type.isExplicitHandle ) |
| 8339 | { |
| 8340 | // Get the handle to the object that will be used for the value assignment |
| 8341 | if( ProcessPropertyGetAccessor(lctx, opNode) < 0 ) |
| 8342 | return -1; |
| 8343 | } |
| 8344 |
nothing calls this directly
no test coverage detected