Symbol * isValidFuncInvocation(Symbol *s, struct ElementArray *ea) { struct ElementArray *params = NULL; Symbol *passedParam, *expectedParam = NULL; int i; // make sure we're given a func and not a proc if (s->kind != FUNC_KIND) { errMsg = customErrorString("Identifier %s cannot be " "called as a function.", s->name); e = recordError(errMsg, yylineno, colno, SEMANTIC); return 0; } params = s->kindPtr.FuncKind->params; if (!params) { // special case of predefined-function // TODO check what types are acceptable, // for now assuming all types return getTypeSym(s); } else if (params->nElements != ea->nElements) { errMsg = customErrorString("Procedure %s expects %d " "parameters, got %d", s->name, params->nElements, ea->nElements); e = recordError(errMsg, yylineno, colno, SEMANTIC); return NULL; } // TODO: should'nt call to is areSameType below be a call to // are assignment compatible? for (i = 0; i < params->nElements; i++) { passedParam = ((struct treeNode *)getElementAt(ea, i))->symbol; expectedParam = (Symbol *) getElementAt(params, i); if (!isAssignmentCompat(expectedParam,passedParam)) { errMsg = customErrorString("Procedure %s expects " "argument of type %s at index %d, but got " "argument of type %s", s->name, typeToString(getType(expectedParam)),i, typeToString(getType(passedParam))); e = recordError(errMsg, yylineno, colno, SEMANTIC); return NULL; } } return getTypeSym(s); }
void QuadraticBezierCurvesScene::QuadraticBezierCurves::erase () { if (parent->isStatic() || anyMappedBuffers()) { recordError(RTC_INVALID_OPERATION); return; } Geometry::erase(); }
void QuadraticBezierCurvesScene::QuadraticBezierCurves::setMask (unsigned mask) { if (parent->isStatic() && parent->isBuild()) { recordError(RTC_INVALID_OPERATION); return; } this->mask = mask; }
void QuadraticBezierCurvesScene::QuadraticBezierCurves::setBuffer(RTCBufferType type, void* ptr, size_t offset, size_t stride) { if (parent->isStatic() && parent->isBuild()) { recordError(RTC_INVALID_OPERATION); return; } /* verify that all accesses are 4 bytes aligned */ if (((size_t(ptr) + offset) & 0x3) || (stride & 0x3)) { recordError(RTC_INVALID_OPERATION); return; } /* verify that all vertex accesses are 16 bytes aligned */ #if defined(__MIC__) if (type == RTC_VERTEX_BUFFER0 || type == RTC_VERTEX_BUFFER1) { if (((size_t(ptr) + offset) & 0xF) || (stride & 0xF)) { recordError(RTC_INVALID_OPERATION); return; } } #endif switch (type) { case RTC_INDEX_BUFFER : curves.set(ptr,offset,stride); break; case RTC_VERTEX_BUFFER0: vertices[0].set(ptr,offset,stride); if (numVertices) { /* test if array is properly padded */ volatile int w = *((int*)&vertices[0][numVertices-1]+3); // FIXME: is failing hard avoidable? } break; case RTC_VERTEX_BUFFER1: vertices[1].set(ptr,offset,stride); if (numVertices) { /* test if array is properly padded */ volatile int w = *((int*)&vertices[1][numVertices-1]+3); // FIXME: is failing hard avoidable? } break; default: recordError(RTC_INVALID_ARGUMENT); break; } }
void QmcTypeCompiler::recordError(const QV4::CompiledData::Location& location, const QString& description) { QQmlError error; error.setLine(location.line); error.setColumn(location.column); error.setUrl(compiledData->url); error.setDescription(description); recordError(error); }
/* * Return 1 if valid invocation, 0 otherwise. */ int isValidProcInvocation(Symbol *s, struct ElementArray *ea) { struct ElementArray *params = NULL; Symbol *passedParam, *expectedParam = NULL; int i; // make sure we're given a proc and not a func or any other symbol if (s->kind != PROC_KIND) { errMsg = customErrorString("Identifier %s cannot be called " "as a procedure.", s->name); e = recordError(errMsg, yylineno, colno, SEMANTIC); return 0; } params = s->kindPtr.ProcKind->params; if (!params) { // special built-in proc that takes unlimited args // TODO for now just assuming all arguments are valid return 1; } else if (params->nElements != ea->nElements) { errMsg = customErrorString("Procedure %s expects %d " "parameters, got %d", s->name, params->nElements, ea->nElements); e = recordError(errMsg, yylineno, colno, SEMANTIC); return 0; } for (i = 0; (i < params->nElements) && (i < ea->nElements); i++) { passedParam = ((struct treeNode *)getElementAt(ea, i))->symbol; expectedParam = (Symbol *) getElementAt(params, i); if (!isAssignmentCompat(expectedParam, passedParam)) { errMsg = customErrorString("Procedure %s expects " "argument of type %s at index %d, but got " "argument of type %s", s->name, typeToString(getType(expectedParam)), i, typeToString(getType(passedParam))); e = recordError(errMsg, yylineno, colno, SEMANTIC); return 0; } } return 1; }
NABoolean HiveMetaData::validate(Int32 tableId, Int64 redefTS, const char* schName, const char* tblName) { NABoolean result = FALSE; // validate creation timestamp if (!connect()) return FALSE; Int64 currentRedefTime = 0; HVC_RetCode retCode = client_->getRedefTime(schName, tblName, currentRedefTime); if ((retCode != HVC_OK) && (retCode != HVC_DONE)) { return recordError((Int32)retCode, "HiveClient_JNI::getRedefTime()"); } if ((retCode == HVC_DONE) || (currentRedefTime != redefTS)) return result; else return TRUE; return result; }
/* * Create an argument list for function and procedure invocation. * * Return a pointer to a ProxySymbol containing the list. */ struct ElementArray *createArgList(struct treeNode *arg) { struct ElementArray * ea = NULL; if (!arg) { /* ERROR */ return NULL; } if (!(arg->symbol)) return NULL; if ( (arg->symbol->kind == PROC_KIND) || ((arg->symbol->kind == FUNC_KIND) && !(arg->symbol->kindPtr.FuncKind->invocationInstance)) || (arg->symbol->kind == PARAM_KIND) ){ errMsg = customErrorString("Invalid argument type."); recordError(errMsg, yylineno, colno, SEMANTIC); } ea = newElementArray(); growElementArray(ea); appendElement(ea, arg); return ea; }
struct hive_tbl_desc* HiveMetaData::getTableDesc(const char* schemaName, const char* tblName) { struct hive_tbl_desc *ptr = tbl_; while (ptr) { if ( !(strcmp(ptr->tblName_, tblName) ||strcmp(ptr->schName_, schemaName))) { if (validate(ptr->tblID_, ptr->redeftime(), schemaName, tblName)) return ptr; else { // table changed, delete it and re-read below if (tbl_ == ptr) tbl_ = ptr->next_; else { struct hive_tbl_desc *ptr2 = tbl_; while (ptr2) { if (ptr2->next_ == ptr) ptr2->next_ = ptr->next_; ptr2 = ptr2->next_; } } NADELETEBASIC(ptr, CmpCommon::contextHeap()); ptr = NULL; break; } } ptr = ptr->next_; } // table not found in cache, try to read it from metadata hive_tbl_desc * result = NULL; Int64 creationTS; NABoolean needToConnect ; needToConnect = (client_ == NULL); /* Create a connection */ if (needToConnect) if (!connect()) return NULL; NAText* tblStr = new (CmpCommon::statementHeap()) string(); if (!tblStr) return NULL; HVC_RetCode retCode = client_->getHiveTableStr(schemaName, tblName, *tblStr); if ((retCode != HVC_OK) && (retCode != HVC_DONE)) { recordError((Int32)retCode, "HiveClient_JNI::getTableStr()"); return NULL; } if (retCode == HVC_DONE) // table not found. return NULL; NAText tblNameStr; size_t pos = 0; if(!extractValueStr(this, tblStr, pos, "tableName:", ",", tblNameStr, "getTableDesc::tableName:###")) return NULL; NAText schNameStr; pos = 0; if(!extractValueStr(this, tblStr, pos, "dbName:", ",", schNameStr, "getTableDesc::dbName:###")) return NULL; NAText ownerStr; pos = 0; if(!extractValueStr(this, tblStr, pos, "owner:", ",", ownerStr, "getTableDesc:owner:###")) return NULL; NAText createTimeStr; pos = 0; if(!extractValueStr(this, tblStr, pos, "createTime:", ",", createTimeStr, "getTableDesc::createTime:###")) return NULL; creationTS = atol(createTimeStr.c_str()); // TODO: need to handle multiple SDs struct hive_sd_desc* sd = populateSD(this, 0,0, tblStr, pos); if (!sd) return NULL; struct hive_pkey_desc* pkey = populatePartitionKey(this, 0, tblStr, pos); NAText tableTypeStr; pos = 0; if(!extractValueStr(this, tblStr, pos, "tableType:", ")", tableTypeStr, "getTableDesc:tableType:###")) return NULL; result = new (CmpCommon::contextHeap()) struct hive_tbl_desc(0, // no tblID with JNI tblNameStr.c_str(), schNameStr.c_str(), ownerStr.c_str(), tableTypeStr.c_str(), creationTS, sd, pkey); // add the new table to the cache result->next_ = tbl_; tbl_ = result; //delete tblStr ; return result; }
void notDefinedError(char *id) { errMsg = customErrorString("The identifier %s is undefined.", id); recordError(errMsg, yylineno, colno, SEMANTIC); }
void alreadyDefinedError(char *id) { errMsg = customErrorString("The identifer %s is already defined at " "the current scope.", id); recordError(errMsg, yylineno, colno, SEMANTIC); }
bool QmcTypeCompiler::createTypeMap() { // qqmltypecompiler.cpp:81 const QHash<int, QmlCompilation::TypeReference> &resolvedTypes = compilation->typeReferences; for (QHash<int, QmlCompilation::TypeReference>::ConstIterator resolvedType = resolvedTypes.constBegin(), end = resolvedTypes.constEnd(); resolvedType != end; ++resolvedType) { QScopedPointer<QQmlCompiledData::TypeReference> ref(new QQmlCompiledData::TypeReference); QQmlType *qmlType = resolvedType->type; if (resolvedType.value().composite) { // qqmltypecompiler.cpp:87 if (resolvedType->needsCreation && qmlType->isCompositeSingleton()) { QQmlError error; QString reason = tr("Composite Singleton Type %1 is not creatable.").arg(qmlType->qmlTypeName()); error.setDescription(reason); error.setColumn(resolvedType->location.column); error.setLine(resolvedType->location.line); recordError(error); return false; } // qqmltypecompiler.cpp:96 Q_ASSERT(resolvedType->component); Q_ASSERT(resolvedType->component->compiledData); ref->component = resolvedType->component->compiledData; ref->component->addref(); } else if (qmlType) { ref->type = qmlType; Q_ASSERT(ref->type); if (resolvedType->needsCreation && !ref->type->isCreatable()) { QQmlError error; QString reason = ref->type->noCreationReason(); if (reason.isEmpty()) reason = tr("Element is not creatable."); error.setDescription(reason); error.setColumn(resolvedType->location.column); error.setLine(resolvedType->location.line); error.setUrl(compilation->url); recordError(error); return false; } if (ref->type->containsRevisionedAttributes()) { QQmlError cacheError; ref->typePropertyCache = QQmlEnginePrivate::get(compilation->engine)->cache( ref->type, resolvedType->minorVersion, cacheError); if (!ref->typePropertyCache) { cacheError.setColumn(resolvedType->location.column); cacheError.setLine(resolvedType->location.line); recordError(cacheError); return false; } ref->typePropertyCache->addref(); } } ref->majorVersion = resolvedType->majorVersion; ref->minorVersion = resolvedType->minorVersion; ref->doDynamicTypeCheck(); compiledData->resolvedTypes.insert(resolvedType.key(), ref.take()); } return true; }
bool QmcTypeUnitComponentAndAliasResolver::addAliases() { // add aliases //QmcUnitAlias al = {0, 0, 0, 8, 0, 0, 24}; //qmcTypeUnit->unit->aliases.append(al); // see QQmlComponentAndAliasResolver::resolve int effectiveAliasIndex = -1; int effectivePropertyIndex = -1; int effectiveSignalIndex = -1; int currentObjectIndex = -1; QQmlPropertyCache *propertyCache = NULL; foreach (const QmcUnitAlias &alias, qmcTypeUnit->unit->aliases) { if ((int)alias.objectIndex != currentObjectIndex) { currentObjectIndex = alias.objectIndex; effectiveAliasIndex = 0; propertyCache = qmcTypeUnit->propertyCaches.at(alias.objectIndex); effectivePropertyIndex = propertyCache->propertyIndexCacheStart + propertyCache->propertyIndexCache.count(); effectiveSignalIndex = propertyCache->signalHandlerIndexCacheStart + propertyCache->propertyIndexCache.count(); } Q_ASSERT(propertyCache); QQmlVMEMetaData::AliasData aliasData; aliasData.contextIdx = alias.contextIndex; aliasData.propertyIdx = alias.targetPropertyIndex; aliasData.propType = alias.propertyType; aliasData.flags = alias.flags; aliasData.notifySignal = alias.notifySignal; typedef QQmlVMEMetaData VMD; QByteArray &dynamicData = qmcTypeUnit->vmeMetaObjects[alias.objectIndex]; Q_ASSERT(!dynamicData.isEmpty()); VMD *vmd = (QQmlVMEMetaData *)dynamicData.data(); *(vmd->aliasData() + effectiveAliasIndex++) = aliasData; Q_ASSERT(dynamicData.isDetached()); // TBD: propertyCache const QV4::CompiledData::Object *obj = qmcTypeUnit->compiledData->qmlUnit->objectAt(alias.objectIndex); Q_ASSERT(obj); Q_ASSERT(alias.propertyIndex < obj->nProperties); const QV4::CompiledData::Property *p = &obj->propertyTable()[alias.propertyIndex]; Q_ASSERT(p); QString propertyName = qmcTypeUnit->stringAt(p->nameIndex); const QString aliasPropertyValue = qmcTypeUnit->stringAt(p->aliasPropertyValueIndex); //const int idIndex = p->aliasIdValueIndex; const int targetObjectIndex = alias.targetObjectIndex; #if 0 const int idIndex = p->aliasIdValueIndex; const int targetObjectIndex = _idToObjectIndex.value(idIndex, -1); if (targetObjectIndex == -1) { recordError(p->aliasLocation, tr("Invalid alias reference. Unable to find id \"%1\"").arg(stringAt(idIndex))); return false; } #endif QStringRef property; QStringRef subProperty; const int propertySeparator = aliasPropertyValue.indexOf(QLatin1Char('.')); if (propertySeparator != -1) { property = aliasPropertyValue.leftRef(propertySeparator); subProperty = aliasPropertyValue.midRef(propertySeparator + 1); } else property = QStringRef(&aliasPropertyValue, 0, aliasPropertyValue.length()); quint32 propertyFlags = QQmlPropertyData::IsAlias; int type = 0; bool writable = false; bool resettable = false; if (property.isEmpty()) { const QV4::CompiledData::Object *targetObject = qmcTypeUnit->compiledData->qmlUnit->objectAt(targetObjectIndex); QQmlCompiledData::TypeReference *typeRef = qmcTypeUnit->compiledData->resolvedTypes.value(targetObject->inheritedTypeNameIndex); Q_ASSERT(typeRef); if (typeRef->type) type = typeRef->type->typeId(); else type = typeRef->component->metaTypeId; //flags |= QML_ALIAS_FLAG_PTR; propertyFlags |= QQmlPropertyData::IsQObjectDerived; } else { QQmlPropertyCache *targetCache = qmcTypeUnit->propertyCaches.at(targetObjectIndex); Q_ASSERT(targetCache); QmlIR::PropertyResolver resolver(targetCache); QQmlPropertyData *targetProperty = resolver.property(property.toString()); if (!targetProperty || targetProperty->coreIndex > 0x0000FFFF) { return false; } //propIdx = targetProperty->coreIndex; type = targetProperty->propType; writable = targetProperty->isWritable(); resettable = targetProperty->isResettable(); //notifySignal = targetProperty->notifyIndex; if (!subProperty.isEmpty()) { QQmlValueType *valueType = QQmlValueTypeFactory::valueType(type); if (!valueType) { return false; } //propType = type; int valueTypeIndex = valueType->metaObject()->indexOfProperty(subProperty.toString().toUtf8().constData()); if (valueTypeIndex == -1) { return false; } Q_ASSERT(valueTypeIndex <= 0x0000FFFF); //propIdx |= (valueTypeIndex << 16); if (valueType->metaObject()->property(valueTypeIndex).isEnumType()) type = QVariant::Int; else type = valueType->metaObject()->property(valueTypeIndex).userType(); } else { if (targetProperty->isEnum()) { type = QVariant::Int; } else { // Copy type flags propertyFlags |= targetProperty->getFlags() & QQmlPropertyData::PropTypeFlagMask; if (targetProperty->isVarProperty()) propertyFlags |= QQmlPropertyData::IsQVariant; #if 0 if (targetProperty->isQObject()) flags |= QML_ALIAS_FLAG_PTR; #endif } } } if (!(p->flags & QV4::CompiledData::Property::IsReadOnly) && writable) propertyFlags |= QQmlPropertyData::IsWritable; else propertyFlags &= ~QQmlPropertyData::IsWritable; if (resettable) propertyFlags |= QQmlPropertyData::IsResettable; else propertyFlags &= ~QQmlPropertyData::IsResettable; if ((int)alias.propertyIndex == obj->indexOfDefaultProperty) propertyCache->_defaultPropertyName = propertyName; propertyCache->appendProperty(propertyName, propertyFlags, effectivePropertyIndex++, type, effectiveSignalIndex++); } return true; }