diff options
| author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-04-13 01:34:08 +0200 | 
|---|---|---|
| committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2016-04-25 22:24:17 +0200 | 
| commit | e6b3ad3c5b390851db61e54f96c980bad8aff701 (patch) | |
| tree | 17a22acb4c32e8523d3f28bfc6f028ef5ce72413 /src | |
| parent | a9f2e3dfc70250c13df29091defa67fe19525f6b (diff) | |
Implement resolution of ReferenceTypes with the "@" syntax.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/parser/ParserScope.cpp | 24 | 
1 files changed, 21 insertions, 3 deletions
| diff --git a/src/core/parser/ParserScope.cpp b/src/core/parser/ParserScope.cpp index 0be8a22..045facd 100644 --- a/src/core/parser/ParserScope.cpp +++ b/src/core/parser/ParserScope.cpp @@ -344,14 +344,16 @@ bool ParserScope::resolveType(const std::vector<std::string> &path,  {  	// Check whether the given path denotes an array, if yes recursively resolve  	// the inner type and wrap it in an array type (this allows multi -	// dimensional arrays). +	// dimensional arrays). Perform a similar procedure for reference types, +	// denoted using '@'.  	if (!path.empty()) {  		const std::string &last = path.back(); +		const std::string &first = path.front();  		if (last.size() >= 2 && last.substr(last.size() - 2, 2) == "[]") {  			// Type ends with "[]", remove this from the last element in the  			// list  			std::vector<std::string> p = path; -			p.back() = p.back().substr(0, last.size() - 2); +			p.back() = last.substr(0, last.size() - 2);  			// Resolve the rest of the type  			return resolveType(p, owner, logger, @@ -359,12 +361,28 @@ bool ParserScope::resolveType(const std::vector<std::string> &path,  			                                    Handle<Node> owner,  			                                    Logger &logger) {  				if (resolved != nullptr) { -					Rooted<ArrayType> arr{new ArrayType{resolved.cast<Type>()}}; +					Rooted<ArrayType> arr{new ArrayType(resolved.cast<Type>())};  					resultCallback(arr, owner, logger);  				} else {  					resultCallback(nullptr, owner, logger);  				}  			}); +		} else if (first.size() >= 1 && first[0] == '@') { +			// If only the '@' is given, create and return an empty reference +			// type. +			if (first.size() == 1 && path.size() == 1) { +				resultCallback( +				    new ReferenceType(owner->getManager(), "@", nullptr), owner, +				    logger); +				return true; +			} + +			// Remove the '@', try to resolve the rest as an element of the +			// class "Descriptor" +			std::vector<std::string> p = path; +			p.front() = first.substr(1, first.size() - 1); +			return resolve(&RttiTypes::Descriptor, p, owner, logger, +			               resultCallback);  		}  	} | 
