| 3014 | } |
| 3015 | |
| 3016 | bool asCCompiler::CompileAutoType(asCDataType &type, asCExprContext &compiledCtx, asCScriptNode *node, asCScriptNode *errNode) |
| 3017 | { |
| 3018 | if( node && node->nodeType == snAssignment ) |
| 3019 | { |
| 3020 | int r = CompileAssignment(node, &compiledCtx); |
| 3021 | if( r >= 0 ) |
| 3022 | { |
| 3023 | // Must not have unused ambiguous names |
| 3024 | if (compiledCtx.IsClassMethod() || compiledCtx.IsGlobalFunc()) |
| 3025 | { |
| 3026 | // TODO: Should mention that the problem is the ambiguous name |
| 3027 | Error(TXT_CANNOT_RESOLVE_AUTO, errNode); |
| 3028 | return false; |
| 3029 | } |
| 3030 | |
| 3031 | // Must not have unused anonymous functions |
| 3032 | if (compiledCtx.IsLambda()) |
| 3033 | { |
| 3034 | // TODO: Should mention that the problem is the anonymous function |
| 3035 | Error(TXT_CANNOT_RESOLVE_AUTO, errNode); |
| 3036 | return false; |
| 3037 | } |
| 3038 | |
| 3039 | // Must not be a null handle |
| 3040 | if (compiledCtx.type.dataType.IsNullHandle()) |
| 3041 | { |
| 3042 | // TODO: Should mention that the problem is the null pointer |
| 3043 | Error(TXT_CANNOT_RESOLVE_AUTO, errNode); |
| 3044 | return false; |
| 3045 | } |
| 3046 | |
| 3047 | asCDataType newType = compiledCtx.type.dataType; |
| 3048 | |
| 3049 | // Handle const qualifier on auto |
| 3050 | if (type.IsReadOnly()) |
| 3051 | newType.MakeReadOnly(true); |
| 3052 | else if (type.IsHandleToConst()) |
| 3053 | newType.MakeHandleToConst(true); |
| 3054 | else if (newType.IsPrimitive()) |
| 3055 | newType.MakeReadOnly(false); |
| 3056 | |
| 3057 | // Handle reference/value stuff |
| 3058 | newType.MakeReference(false); |
| 3059 | if (!newType.IsObjectHandle()) |
| 3060 | { |
| 3061 | // We got a value object or an object reference. |
| 3062 | // Turn the variable into a handle if specified |
| 3063 | // as auto@, otherwise make it a 'value'. |
| 3064 | if (type.IsHandleToAuto()) |
| 3065 | { |
| 3066 | if (newType.MakeHandle(true) < 0) |
| 3067 | { |
| 3068 | Error(TXT_OBJECT_HANDLE_NOT_SUPPORTED, errNode); |
| 3069 | return false; |
| 3070 | } |
| 3071 | } |
| 3072 | } |
| 3073 |
nothing calls this directly
no test coverage detected