Changeset View
Changeset View
Standalone View
Standalone View
duchain/builders/typebuilder.cpp
Context not available. | |||||
358 | void TypeBuilder::visitParameter(ParameterAst *node) | 358 | void TypeBuilder::visitParameter(ParameterAst *node) | ||
---|---|---|---|---|---|
359 | { | 359 | { | ||
360 | AbstractType::Ptr type; | 360 | AbstractType::Ptr type; | ||
361 | if (node->isVariadic != -1) { | 361 | if (node->parameterType) { | ||
362 | if (node->parameterType) { | 362 | if (node->parameterType->objectType) { | ||
363 | //don't use openTypeFromName as it uses cursor for findDeclarations | 363 | //don't use openTypeFromName as it uses cursor for findDeclarations | ||
364 | DeclarationPointer decl = findDeclarationImport(ClassDeclarationType, | 364 | DeclarationPointer decl = findDeclarationImport(ClassDeclarationType, | ||
365 | identifierForNamespace(node->parameterType, editor())); | 365 | identifierForNamespace(node->parameterType->objectType, editor())); | ||
366 | if (decl) { | 366 | if (decl) { | ||
367 | IndexedContainer *container = new IndexedContainer(); | 367 | type = decl->abstractType(); | ||
368 | const IndexedString *containerType = new IndexedString("array"); | | |||
369 | container->addEntry(decl->abstractType()); | | |||
370 | container->setPrettyName(*containerType); | | |||
371 | type = AbstractType::Ptr(container); | | |||
372 | } | 368 | } | ||
373 | } else { | 369 | } else if (node->parameterType->arrayType != -1) { | ||
374 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); | 370 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); | ||
371 | } else if (node->parameterType->boolType != -1) { | ||||
372 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeBoolean)); | ||||
373 | } else if (node->parameterType->floatType != -1) { | ||||
374 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeFloat)); | ||||
375 | } else if (node->parameterType->intType != -1) { | ||||
376 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeInt)); | ||||
377 | } else if (node->parameterType->stringType != -1) { | ||||
378 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeString)); | ||||
379 | } else if (node->parameterType->iterableType != -1) { | ||||
380 | DeclarationPointer traversableDecl = findDeclarationImport(ClassDeclarationType, QualifiedIdentifier("traversable")); | ||||
381 | | ||||
382 | if (traversableDecl) { | ||||
383 | UnsureType::Ptr unsure(new UnsureType()); | ||||
384 | AbstractType::Ptr arrayType = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); | ||||
385 | unsure->addType(arrayType->indexed()); | ||||
386 | unsure->addType(traversableDecl->abstractType()->indexed()); | ||||
387 | | ||||
388 | type = AbstractType::Ptr(unsure); | ||||
389 | } | ||||
375 | } | 390 | } | ||
376 | } else if (node->parameterType) { | 391 | | ||
377 | //don't use openTypeFromName as it uses cursor for findDeclarations | 392 | if (type && node->parameterType->isNullable != -1) { | ||
378 | DeclarationPointer decl = findDeclarationImport(ClassDeclarationType, | 393 | AbstractType::Ptr nullType = AbstractType::Ptr(new IntegralType(IntegralType::TypeNull)); | ||
379 | identifierForNamespace(node->parameterType, editor())); | 394 | if (type.cast<UnsureType>()) { | ||
380 | if (decl) { | 395 | UnsureType::Ptr unsure = type.cast<UnsureType>(); | ||
381 | type = decl->abstractType(); | 396 | unsure->addType(nullType->indexed()); | ||
397 | } else { | ||||
398 | UnsureType::Ptr unsure(new UnsureType()); | ||||
399 | unsure->addType(type->indexed()); | ||||
400 | unsure->addType(nullType->indexed()); | ||||
401 | | ||||
402 | type = AbstractType::Ptr(unsure); | ||||
403 | } | ||||
382 | } | 404 | } | ||
383 | } else if (node->arrayType != -1) { | | |||
384 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeArray)); | | |||
385 | } else if (node->defaultValue) { | 405 | } else if (node->defaultValue) { | ||
386 | ExpressionVisitor v(editor()); | 406 | ExpressionVisitor v(editor()); | ||
387 | node->defaultValue->ducontext = currentContext(); | 407 | node->defaultValue->ducontext = currentContext(); | ||
Context not available. | |||||
403 | type = p.cast<AbstractType>(); | 423 | type = p.cast<AbstractType>(); | ||
404 | } | 424 | } | ||
405 | 425 | | |||
426 | if (node->isVariadic != -1) { | ||||
427 | IndexedContainer *container = new IndexedContainer(); | ||||
428 | const IndexedString *containerType = new IndexedString("array"); | ||||
429 | container->addEntry(type); | ||||
430 | container->setPrettyName(*containerType); | ||||
431 | type = AbstractType::Ptr(container); | ||||
432 | } | ||||
433 | | ||||
406 | openAbstractType(type); | 434 | openAbstractType(type); | ||
407 | TypeBuilderBase::visitParameter(node); | 435 | TypeBuilderBase::visitParameter(node); | ||
408 | closeType(); | 436 | closeType(); | ||
Context not available. |