Changeset View
Changeset View
Standalone View
Standalone View
duchain/builders/typebuilder.cpp
Show First 20 Lines • Show All 258 Lines • ▼ Show 20 Line(s) | 248 | if (node) { | |||
---|---|---|---|---|---|
259 | } | 259 | } | ||
260 | } | 260 | } | ||
261 | if (!type) { | 261 | if (!type) { | ||
262 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeMixed)); | 262 | type = AbstractType::Ptr(new IntegralType(IntegralType::TypeMixed)); | ||
263 | } | 263 | } | ||
264 | return type; | 264 | return type; | ||
265 | } | 265 | } | ||
266 | 266 | | |||
267 | FunctionType::Ptr TypeBuilder::openFunctionType(AstNode* node) | | |||
268 | { | | |||
269 | FunctionType::Ptr functionType = FunctionType::Ptr(new FunctionType()); | | |||
270 | | ||||
271 | openType(functionType); | | |||
272 | | ||||
273 | functionType->setReturnType(parseDocComment(node, QStringLiteral("return"))); | | |||
274 | m_gotReturnTypeFromDocComment = functionType->returnType(); | | |||
275 | updateCurrentType(); | | |||
276 | | ||||
277 | return functionType; | | |||
278 | } | | |||
279 | | ||||
280 | void TypeBuilder::visitClassDeclarationStatement(ClassDeclarationStatementAst* node) | 267 | void TypeBuilder::visitClassDeclarationStatement(ClassDeclarationStatementAst* node) | ||
281 | { | 268 | { | ||
282 | // the predeclaration builder should have set up a type already | 269 | // the predeclaration builder should have set up a type already | ||
283 | // and the declarationbuilder should have set that as current type | 270 | // and the declarationbuilder should have set that as current type | ||
284 | Q_ASSERT(hasCurrentType() && currentType<StructureType>()); | 271 | Q_ASSERT(hasCurrentType() && currentType<StructureType>()); | ||
285 | 272 | | |||
286 | TypeBuilderBase::visitClassDeclarationStatement(node); | 273 | TypeBuilderBase::visitClassDeclarationStatement(node); | ||
287 | } | 274 | } | ||
Show All 16 Lines | 286 | { | |||
304 | TypeBuilderBase::visitTraitDeclarationStatement(node); | 291 | TypeBuilderBase::visitTraitDeclarationStatement(node); | ||
305 | } | 292 | } | ||
306 | 293 | | |||
307 | void TypeBuilder::visitClassStatement(ClassStatementAst *node) | 294 | void TypeBuilder::visitClassStatement(ClassStatementAst *node) | ||
308 | { | 295 | { | ||
309 | if (node->methodName) { | 296 | if (node->methodName) { | ||
310 | //method declaration | 297 | //method declaration | ||
311 | m_currentFunctionParams = parseDocCommentParams(node); | 298 | m_currentFunctionParams = parseDocCommentParams(node); | ||
312 | openFunctionType(node); | 299 | | ||
300 | FunctionType::Ptr functionType = FunctionType::Ptr(new FunctionType()); | ||||
301 | openType(functionType); | ||||
302 | | ||||
303 | AbstractType::Ptr phpdocReturnType = parseDocComment(node, QStringLiteral("return")); | ||||
304 | functionType->setReturnType(returnType(node->returnType, phpdocReturnType, editor(), currentContext())); | ||||
305 | m_gotReturnTypeFromDocComment = functionType->returnType(); | ||||
306 | updateCurrentType(); | ||||
307 | | ||||
313 | TypeBuilderBase::visitClassStatement(node); | 308 | TypeBuilderBase::visitClassStatement(node); | ||
314 | if (currentType<FunctionType>() && !currentType<FunctionType>()->returnType()) { | 309 | if (currentType<FunctionType>() && !currentType<FunctionType>()->returnType()) { | ||
315 | currentType<FunctionType>()->setReturnType(AbstractType::Ptr(new IntegralType(IntegralType::TypeVoid))); | 310 | currentType<FunctionType>()->setReturnType(AbstractType::Ptr(new IntegralType(IntegralType::TypeVoid))); | ||
316 | } | 311 | } | ||
317 | closeType(); | 312 | closeType(); | ||
318 | } else { | 313 | } else { | ||
319 | //member-variable | 314 | //member-variable | ||
320 | parseDocComment(node, QStringLiteral("var")); | 315 | parseDocComment(node, QStringLiteral("var")); | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
375 | { | 370 | { | ||
376 | m_currentFunctionParams = parseDocCommentParams(node); | 371 | m_currentFunctionParams = parseDocCommentParams(node); | ||
377 | // the predeclarationbuilder should have already built the type | 372 | // the predeclarationbuilder should have already built the type | ||
378 | // and the declarationbuilder should have set it to open | 373 | // and the declarationbuilder should have set it to open | ||
379 | Q_ASSERT(hasCurrentType()); | 374 | Q_ASSERT(hasCurrentType()); | ||
380 | FunctionType::Ptr type = currentType<FunctionType>(); | 375 | FunctionType::Ptr type = currentType<FunctionType>(); | ||
381 | Q_ASSERT(type); | 376 | Q_ASSERT(type); | ||
382 | 377 | | |||
383 | type->setReturnType(parseDocComment(node, QStringLiteral("return"))); | 378 | AbstractType::Ptr phpdocReturnType = parseDocComment(node, QStringLiteral("return")); | ||
379 | type->setReturnType(returnType(node->returnType, phpdocReturnType, editor(), currentContext())); | ||||
384 | m_gotReturnTypeFromDocComment = type->returnType(); | 380 | m_gotReturnTypeFromDocComment = type->returnType(); | ||
385 | 381 | | |||
386 | updateCurrentType(); | 382 | updateCurrentType(); | ||
387 | 383 | | |||
388 | TypeBuilderBase::visitFunctionDeclarationStatement(node); | 384 | TypeBuilderBase::visitFunctionDeclarationStatement(node); | ||
389 | 385 | | |||
390 | if (!type->returnType()) { | 386 | if (!type->returnType()) { | ||
391 | type->setReturnType(AbstractType::Ptr(new IntegralType(IntegralType::TypeVoid))); | 387 | type->setReturnType(AbstractType::Ptr(new IntegralType(IntegralType::TypeVoid))); | ||
392 | } | 388 | } | ||
393 | } | 389 | } | ||
394 | 390 | | |||
395 | void TypeBuilder::visitClosure(ClosureAst* node) | 391 | void TypeBuilder::visitClosure(ClosureAst* node) | ||
396 | { | 392 | { | ||
397 | m_currentFunctionParams = parseDocCommentParams(node); | 393 | m_currentFunctionParams = parseDocCommentParams(node); | ||
398 | FunctionType::Ptr type = FunctionType::Ptr(new FunctionType()); | 394 | FunctionType::Ptr type = FunctionType::Ptr(new FunctionType()); | ||
399 | openType(type); | 395 | openType(type); | ||
400 | 396 | | |||
401 | type->setReturnType(parseDocComment(node, QStringLiteral("return"))); | 397 | AbstractType::Ptr phpdocReturnType = parseDocComment(node, QStringLiteral("return")); | ||
398 | type->setReturnType(returnType(node->returnType, phpdocReturnType, editor(), currentContext())); | ||||
402 | m_gotReturnTypeFromDocComment = type->returnType(); | 399 | m_gotReturnTypeFromDocComment = type->returnType(); | ||
403 | 400 | | |||
404 | updateCurrentType(); | 401 | updateCurrentType(); | ||
405 | 402 | | |||
406 | TypeBuilderBase::visitClosure(node); | 403 | TypeBuilderBase::visitClosure(node); | ||
407 | 404 | | |||
408 | if (!type->returnType()) { | 405 | if (!type->returnType()) { | ||
409 | type->setReturnType(AbstractType::Ptr(new IntegralType(IntegralType::TypeVoid))); | 406 | type->setReturnType(AbstractType::Ptr(new IntegralType(IntegralType::TypeVoid))); | ||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |