Changeset View
Changeset View
Standalone View
Standalone View
duchain/expressionvisitor.cpp
Show First 20 Lines • Show All 365 Lines • ▼ Show 20 Line(s) | 365 | } else if (node->expr) { | |||
---|---|---|---|---|---|
366 | //static function call foo::{expr}() | 366 | //static function call foo::{expr}() | ||
367 | const QualifiedIdentifier id = identifierForNamespace(node->stringFunctionNameOrClass, m_editor); | 367 | const QualifiedIdentifier id = identifierForNamespace(node->stringFunctionNameOrClass, m_editor); | ||
368 | DeclarationPointer dec = findDeclarationImport(ClassDeclarationType, id); | 368 | DeclarationPointer dec = findDeclarationImport(ClassDeclarationType, id); | ||
369 | usingDeclaration(node->stringFunctionNameOrClass->namespaceNameSequence->back()->element, dec); | 369 | usingDeclaration(node->stringFunctionNameOrClass->namespaceNameSequence->back()->element, dec); | ||
370 | buildNamespaceUses(node->stringFunctionNameOrClass, id); | 370 | buildNamespaceUses(node->stringFunctionNameOrClass, id); | ||
371 | m_result.setDeclaration(dec); | 371 | m_result.setDeclaration(dec); | ||
372 | } else { | 372 | } else { | ||
373 | //global function call foo(); | 373 | //global function call foo(); | ||
374 | const QualifiedIdentifier id = identifierForNamespace(node->stringFunctionNameOrClass, m_editor); | 374 | QualifiedIdentifier id = identifierForNamespace(node->stringFunctionNameOrClass, m_editor); | ||
375 | DeclarationPointer dec = findDeclarationImport(FunctionDeclarationType, id); | 375 | DeclarationPointer dec = findDeclarationImport(FunctionDeclarationType, id); | ||
376 | if (!dec) { | ||||
377 | id.setExplicitlyGlobal(true); | ||||
378 | dec = findDeclarationImport(FunctionDeclarationType, id); | ||||
379 | } | ||||
376 | ifDebug(qCDebug(DUCHAIN) << "function call of" << (dec ? dec->toString() : QString("function not found"));) | 380 | ifDebug(qCDebug(DUCHAIN) << "function call of" << (dec ? dec->toString() : QString("function not found"));) | ||
377 | m_result.setDeclaration(dec); | 381 | m_result.setDeclaration(dec); | ||
378 | usingDeclaration(node->stringFunctionNameOrClass->namespaceNameSequence->back()->element, dec); | 382 | usingDeclaration(node->stringFunctionNameOrClass->namespaceNameSequence->back()->element, dec); | ||
379 | buildNamespaceUses(node->stringFunctionNameOrClass, id); | 383 | buildNamespaceUses(node->stringFunctionNameOrClass, id); | ||
380 | if (dec) { | 384 | if (dec) { | ||
381 | FunctionType::Ptr function = dec->type<FunctionType>(); | 385 | FunctionType::Ptr function = dec->type<FunctionType>(); | ||
382 | if (function) { | 386 | if (function) { | ||
383 | m_result.setType(function->returnType()); | 387 | m_result.setType(function->returnType()); | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 456 | if (str == QLatin1String("true") || str == QLatin1String("false")) { | |||
453 | m_result.setType(AbstractType::Ptr(new IntegralType(IntegralType::TypeBoolean))); | 457 | m_result.setType(AbstractType::Ptr(new IntegralType(IntegralType::TypeBoolean))); | ||
454 | } else if (str == QLatin1String("null")) { | 458 | } else if (str == QLatin1String("null")) { | ||
455 | m_result.setType(AbstractType::Ptr(new IntegralType(IntegralType::TypeNull))); | 459 | m_result.setType(AbstractType::Ptr(new IntegralType(IntegralType::TypeNull))); | ||
456 | } else { | 460 | } else { | ||
457 | //constant (created with declare('foo', 'bar')) or const Foo = 1; | 461 | //constant (created with declare('foo', 'bar')) or const Foo = 1; | ||
458 | QualifiedIdentifier id = identifierForNamespace(node->constant, m_editor, true); | 462 | QualifiedIdentifier id = identifierForNamespace(node->constant, m_editor, true); | ||
459 | DeclarationPointer declaration = findDeclarationImport(ConstantDeclarationType, id); | 463 | DeclarationPointer declaration = findDeclarationImport(ConstantDeclarationType, id); | ||
460 | if (!declaration) { | 464 | if (!declaration) { | ||
465 | id.setExplicitlyGlobal(true); | ||||
466 | declaration = findDeclarationImport(ConstantDeclarationType, id); | ||||
467 | } | ||||
468 | if (!declaration) { | ||||
461 | ///TODO: is this really wanted? | 469 | ///TODO: is this really wanted? | ||
462 | //it could also be a global function call, without () | 470 | //it could also be a global function call, without () | ||
463 | declaration = findDeclarationImport(FunctionDeclarationType, id); | 471 | declaration = findDeclarationImport(FunctionDeclarationType, id); | ||
464 | } | 472 | } | ||
465 | m_result.setDeclaration(declaration); | 473 | m_result.setDeclaration(declaration); | ||
466 | usingDeclaration(node->constant->namespaceNameSequence->back()->element, declaration); | 474 | usingDeclaration(node->constant->namespaceNameSequence->back()->element, declaration); | ||
467 | buildNamespaceUses(node->constant, id); | 475 | buildNamespaceUses(node->constant, id); | ||
468 | } | 476 | } | ||
▲ Show 20 Lines • Show All 426 Lines • Show Last 20 Lines |