Changeset View
Changeset View
Standalone View
Standalone View
duchain/builders/declarationbuilder.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
69 | void DeclarationBuilder::getVariableIdentifier(VariableAst* node, | 69 | void DeclarationBuilder::getVariableIdentifier(VariableAst* node, | ||
70 | QualifiedIdentifier &identifier, | 70 | QualifiedIdentifier &identifier, | ||
71 | QualifiedIdentifier &parent, | 71 | QualifiedIdentifier &parent, | ||
72 | AstNode* &targetNode, | 72 | AstNode* &targetNode, | ||
73 | bool &arrayAccess) | 73 | bool &arrayAccess) | ||
74 | { | 74 | { | ||
75 | parent = QualifiedIdentifier(); | 75 | parent = QualifiedIdentifier(); | ||
76 | if ( node->variablePropertiesSequence ) { | 76 | if ( node->variablePropertiesSequence ) { | ||
77 | // at least one "->" in the assigment target | 77 | // at least one "->" in the assignment target | ||
78 | // => find he parent of the target | 78 | // => find he parent of the target | ||
79 | // => find the target (last object property) | 79 | // => find the target (last object property) | ||
80 | if ( node->variablePropertiesSequence->count() == 1 ) { | 80 | if ( node->variablePropertiesSequence->count() == 1 ) { | ||
81 | // $parent->target | 81 | // $parent->target | ||
82 | ///TODO: $parent[0]->target = ... (we don't know the type of [0] yet, need proper array handling first) | 82 | ///TODO: $parent[0]->target = ... (we don't know the type of [0] yet, need proper array handling first) | ||
83 | if ( node->var && node->var->baseVariable && node->var->baseVariable->var | 83 | if ( node->var && node->var->baseVariable && node->var->baseVariable->var | ||
84 | && !node->var->baseVariable->offsetItemsSequence ) { | 84 | && !node->var->baseVariable->offsetItemsSequence ) { | ||
85 | parent = identifierForNode( | 85 | parent = identifierForNode( | ||
▲ Show 20 Lines • Show All 1228 Lines • ▼ Show 20 Line(s) | 1303 | if ( !alreadyDeclared && !m_findVariable.identifier.isEmpty() && currentAbstractType()) { | |||
1314 | 1314 | | |||
1315 | if ( !m_findVariable.parentIdentifier.isEmpty() ) { | 1315 | if ( !m_findVariable.parentIdentifier.isEmpty() ) { | ||
1316 | // assignment to class members | 1316 | // assignment to class members | ||
1317 | 1317 | | |||
1318 | if ( DUContext* ctx = getClassContext(m_findVariable.parentIdentifier, currentContext()) ) { | 1318 | if ( DUContext* ctx = getClassContext(m_findVariable.parentIdentifier, currentContext()) ) { | ||
1319 | declareClassMember(ctx, type, m_findVariable.identifier, m_findVariable.node); | 1319 | declareClassMember(ctx, type, m_findVariable.identifier, m_findVariable.node); | ||
1320 | } | 1320 | } | ||
1321 | } else { | 1321 | } else { | ||
1322 | // assigment to other variables | 1322 | // assignment to other variables | ||
1323 | declareVariable(currentContext(), type, m_findVariable.identifier, m_findVariable.node ); | 1323 | declareVariable(currentContext(), type, m_findVariable.identifier, m_findVariable.node ); | ||
1324 | } | 1324 | } | ||
1325 | } | 1325 | } | ||
1326 | } | 1326 | } | ||
1327 | 1327 | | |||
1328 | void DeclarationBuilder::visitFunctionCall(FunctionCallAst* node) | 1328 | void DeclarationBuilder::visitFunctionCall(FunctionCallAst* node) | ||
1329 | { | 1329 | { | ||
1330 | QualifiedIdentifier id; | 1330 | QualifiedIdentifier id; | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 1417 | { | |||
1421 | 1421 | | |||
1422 | if ( m_findVariable.node && m_currentFunctionType && | 1422 | if ( m_findVariable.node && m_currentFunctionType && | ||
1423 | m_currentFunctionType->arguments().count() > m_functionCallParameterPos) { | 1423 | m_currentFunctionType->arguments().count() > m_functionCallParameterPos) { | ||
1424 | ReferenceType::Ptr refType = m_currentFunctionType->arguments() | 1424 | ReferenceType::Ptr refType = m_currentFunctionType->arguments() | ||
1425 | .at(m_functionCallParameterPos).cast<ReferenceType>(); | 1425 | .at(m_functionCallParameterPos).cast<ReferenceType>(); | ||
1426 | if ( refType ) { | 1426 | if ( refType ) { | ||
1427 | // this argument is referenced, so if the node contains undeclared variables we have | 1427 | // this argument is referenced, so if the node contains undeclared variables we have | ||
1428 | // to declare them with a NULL type, see also: | 1428 | // to declare them with a NULL type, see also: | ||
1429 | // http://de.php.net/manual/en/language.references.whatdo.php | 1429 | // https://de.php.net/manual/en/language.references.whatdo.php | ||
1430 | 1430 | | |||
1431 | // declare with NULL type, just like PHP does | 1431 | // declare with NULL type, just like PHP does | ||
1432 | declareFoundVariable(AbstractType::Ptr(new IntegralType(IntegralType::TypeNull))); | 1432 | declareFoundVariable(AbstractType::Ptr(new IntegralType(IntegralType::TypeNull))); | ||
1433 | } | 1433 | } | ||
1434 | } | 1434 | } | ||
1435 | 1435 | | |||
1436 | if (m_functionCallPreviousArgument && m_functionCallPreviousArgument->isVariadic != -1 && node->isVariadic == -1) { | 1436 | if (m_functionCallPreviousArgument && m_functionCallPreviousArgument->isVariadic != -1 && node->isVariadic == -1) { | ||
1437 | reportError(i18n("Cannot use positional argument after argument unpacking"), node); | 1437 | reportError(i18n("Cannot use positional argument after argument unpacking"), node); | ||
▲ Show 20 Lines • Show All 317 Lines • Show Last 20 Lines |