@@ -89,6 +89,7 @@ import {
8989 AssertionExpression ,
9090 BinaryExpression ,
9191 CallExpression ,
92+ CommaExpression ,
9293 ElementAccessExpression ,
9394 FloatLiteralExpression ,
9495 IdentifierExpression ,
@@ -338,7 +339,7 @@ export class Compiler extends DiagnosticEmitter {
338339 }
339340
340341 compileGlobal ( global : Global ) : bool {
341- if ( global . isCompiled || ( global . isBuiltIn && compileBuiltinGetConstant ( this , global ) ) )
342+ if ( global . isCompiled || global . isBuiltIn )
342343 return true ;
343344
344345 var declaration = global . declaration ;
@@ -1103,6 +1104,10 @@ export class Compiler extends DiagnosticEmitter {
11031104 expr = this . compileCallExpression ( < CallExpression > expression , contextualType ) ;
11041105 break ;
11051106
1107+ case NodeKind . COMMA :
1108+ expr = this . compileCommaExpression ( < CommaExpression > expression , contextualType ) ;
1109+ break ;
1110+
11061111 case NodeKind . ELEMENTACCESS :
11071112 expr = this . compileElementAccessExpression ( < ElementAccessExpression > expression , contextualType ) ;
11081113 break ;
@@ -2123,8 +2128,13 @@ export class Compiler extends DiagnosticEmitter {
21232128 var elementType : Type ;
21242129 switch ( element . kind ) {
21252130
2126- case ElementKind . LOCAL :
21272131 case ElementKind . GLOBAL :
2132+ if ( ! this . compileGlobal ( < Global > element ) ) // reports; not yet compiled if a static field compiled as a global
2133+ return this . module . createUnreachable ( ) ;
2134+ assert ( ( < Global > element ) . type != Type . void ) ;
2135+ // fall-through
2136+
2137+ case ElementKind . LOCAL :
21282138 case ElementKind . FIELD :
21292139 elementType = ( < VariableLikeElement > element ) . type ;
21302140 break ;
@@ -2356,6 +2366,16 @@ export class Compiler extends DiagnosticEmitter {
23562366 return this . module . createCall ( functionInstance . internalName , operands , functionInstance . returnType . toNativeType ( ) ) ;
23572367 }
23582368
2369+ compileCommaExpression ( expression : CommaExpression , contextualType : Type ) : ExpressionRef {
2370+ var expressions = expression . expressions ;
2371+ var k = expressions . length ;
2372+ var exprs = new Array < ExpressionRef > ( k -- ) ;
2373+ for ( var i = 0 ; i < k ; ++ i )
2374+ exprs [ i ] = this . compileExpression ( expressions [ i ] , Type . void ) ; // drop all
2375+ exprs [ i ] = this . compileExpression ( expressions [ i ] , contextualType ) ; // except last
2376+ return this . module . createBlock ( null , exprs , this . currentType . toNativeType ( ) ) ;
2377+ }
2378+
23592379 compileElementAccessExpression ( expression : ElementAccessExpression , contextualType : Type ) : ExpressionRef {
23602380 var resolved = this . program . resolveElementAccess ( expression , this . currentFunction ) ; // reports
23612381 if ( ! resolved )
@@ -2426,7 +2446,7 @@ export class Compiler extends DiagnosticEmitter {
24262446
24272447 case ElementKind . GLOBAL :
24282448 if ( element . isBuiltIn )
2429- return compileBuiltinGetConstant ( this , < Global > element ) ;
2449+ return compileBuiltinGetConstant ( this , < Global > element , expression ) ;
24302450 if ( ! this . compileGlobal ( < Global > element ) ) // reports; not yet compiled if a static field compiled as a global
24312451 return this . module . createUnreachable ( ) ;
24322452 assert ( ( < Global > element ) . type != Type . void ) ;
@@ -2500,6 +2520,8 @@ export class Compiler extends DiagnosticEmitter {
25002520 switch ( element . kind ) {
25012521
25022522 case ElementKind . GLOBAL : // static property
2523+ if ( element . isBuiltIn )
2524+ return compileBuiltinGetConstant ( this , < Global > element , propertyAccess ) ;
25032525 if ( ! this . compileGlobal ( < Global > element ) ) // reports; not yet compiled if a static field compiled as a global
25042526 return this . module . createUnreachable ( ) ;
25052527 assert ( ( < Global > element ) . type != Type . void ) ;
0 commit comments