Revision 42f1cff5c1471e6bc3988a9810c20b8bcc1c84dd authored by Tim Foley on 30 October 2017, 15:54:09 UTC, committed by Tim Foley on 30 October 2017, 16:40:04 UTC
This is the first step towards supporting traditional object-oriented method definitions; the second step will be to allow `this` expressions to be implicit.

- Add a test case using explicit `this`, and expected output

- Update parsing logic for expressions so that it handled identifiers similarly to the declaration and statement logic: first try to parse using a syntax declaration looked up in the curent scope, and otherwise fall back to the ordinary `VarExpr` case.

  * As long as I'm making that change: switch `true` and `false` to be parsed via the callback mechanism rather than be special-cased.

  * This change will also help out if we ever wanted to add `super`/`base` expressions, `new`, `sizeof`/`alignof` or any other expression keywords.

- Add a `ThisExpr` node and register a parser callback for it.

- Add semantic checks for `ThisExpr`: basically just look upwards through scopes until we find either an aggregate type declaration or an `extension` declaration, and then use that as the type of the expression.

  - TODO: eventually we need to guard against a `this` expression inside of a `static` member.

- The IR generation logic already handled creation of `this` parameters in function signatures; the missing piece was to register the appropriate parameter in the context, so that we can use it as the lowering of a `this` expression.
1 parent 4ab545b
History
File Mode Size
build
docs
examples
external
source
tests
tools
.gitattributes -rw-r--r-- 95 bytes
.gitignore -rw-r--r-- 398 bytes
.gitmodules -rw-r--r-- 107 bytes
.travis.yml -rw-r--r-- 1.6 KB
CODE_OF_CONDUCT.md -rw-r--r-- 3.1 KB
LICENSE -rw-r--r-- 1.1 KB
Makefile -rw-r--r-- 6.3 KB
README.md -rw-r--r-- 6.2 KB
appveyor.yml -rw-r--r-- 3.5 KB
slang.h -rw-r--r-- 35.2 KB
slang.sln -rw-r--r-- 9.1 KB
test.bat -rw-r--r-- 1.4 KB

README.md

back to top