Parser fixes; Lib updates

This commit is contained in:
dcodeIO
2018-01-29 22:36:07 +01:00
parent 74498852f0
commit 1995bf9eb4
18 changed files with 282 additions and 103 deletions

View File

@ -33,10 +33,12 @@ import {
DecoratorKind,
Expression,
AssertionExpression,
ElementAccessExpression,
IdentifierExpression,
LiteralExpression,
LiteralKind,
ParenthesizedExpression,
PropertyAccessExpression,
StringLiteralExpression,
SuperExpression,
@ -66,7 +68,8 @@ import {
hasDecorator,
hasModifier,
mangleInternalName,
getFirstDecorator
getFirstDecorator,
BinaryExpression
} from "./ast";
import {
@ -1156,8 +1159,22 @@ export class Program extends DiagnosticEmitter {
resolveExpression(expression: Expression, contextualFunction: Function): ResolvedElement | null {
var classType: Class | null;
while (expression.kind == NodeKind.PARENTHESIZED)
expression = (<ParenthesizedExpression>expression).expression;
switch (expression.kind) {
case NodeKind.ASSERTION:
var type = this.resolveType((<AssertionExpression>expression).toType); // reports
if (type && (classType = type.classType))
return (resolvedElement || (resolvedElement = new ResolvedElement())).set(classType);
return null;
case NodeKind.BINARY:
// TODO: string concatenation, mostly
throw new Error("not implemented");
case NodeKind.THIS: // -> Class
if (classType = contextualFunction.instanceMethodOf)
return (resolvedElement || (resolvedElement = new ResolvedElement())).set(classType);