File tree Expand file tree Collapse file tree 3 files changed +30
-18
lines changed
Expand file tree Collapse file tree 3 files changed +30
-18
lines changed Original file line number Diff line number Diff line change @@ -200,11 +200,20 @@ class Bytes {
200200 bout .addByte (el .length );
201201 for ( e in el )
202202 doEncode (e );
203- case ENew (cl ,params ):
203+ case ENew (cl ,params , args ):
204204 doEncodeString (cl );
205205 bout .addByte (params .length );
206206 for ( e in params )
207207 doEncode (e );
208+ if ( storeTypes ) {
209+ if ( args == null )
210+ bout .addByte (0 );
211+ else {
212+ bout .addByte (args .length );
213+ for ( a in args )
214+ encodeType (a );
215+ }
216+ }
208217 case EThrow (e ):
209218 doEncode (e );
210219 case ETry (e ,v ,t ,ecatch ):
@@ -413,7 +422,13 @@ class Bytes {
413422 var el = new Array ();
414423 for ( i in 0 ... getByte () )
415424 el .push (doDecode ());
416- ENew (cl ,el );
425+ var targs = null ;
426+ if ( storeTypes ) {
427+ var len = getByte ();
428+ if ( len > 0 )
429+ targs = [for ( i in 0 ... len ) decodeType ()];
430+ }
431+ ENew (cl ,el ,targs );
417432 case 19 :
418433 EThrow (doDecode ());
419434 case 20 :
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ enum Expr {
5858 EReturn ( ? e : Expr );
5959 EArray ( e : Expr , index : Expr );
6060 EArrayDecl ( e : Array <Expr > );
61- ENew ( cl : String , params : Array <Expr > );
61+ ENew ( cl : String , params : Array <Expr >, ? args : Array < CType > );
6262 EThrow ( e : Expr );
6363 ETry ( e : Expr , v : String , t : Null <CType >, ecatch : Expr );
6464 EObject ( fl : Array <{ name : String , e : Expr }> );
Original file line number Diff line number Diff line change @@ -735,22 +735,19 @@ class Parser {
735735 var e = if ( tk == TSemicolon ) null else parseExpr ();
736736 mk (EReturn (e ),p1 ,if ( e == null ) tokenMax else pmax (e ));
737737 case " new" :
738- var a = new Array ();
739- a .push (getIdent ());
740- while ( true ) {
741- var tk = token ();
742- switch ( tk ) {
743- case TDot :
744- a .push (getIdent ());
745- case TPOpen :
746- break ;
747- default :
748- unexpected (tk );
749- break ;
750- }
738+ var start = tokenMin ;
739+ var t = parseType ();
740+ switch ( t ) {
741+ case CTPath (path , params ):
742+ if ( params != null && ! allowTypes )
743+ error (ECustom (" Type parameters are not allowed" ),start ,tokenMax );
744+ ensure (TPOpen );
745+ var args = parseExprList (TPClose );
746+ mk (ENew (path .join (" ." ),args ,params ),p1 );
747+ default :
748+ error (ECustom (" Invalid type" ),start ,tokenMax );
749+ null ;
751750 }
752- var args = parseExprList (TPClose );
753- mk (ENew (a .join (" ." ),args ),p1 );
754751 case " throw" :
755752 var e = parseExpr ();
756753 mk (EThrow (e ),p1 ,pmax (e ));
You can’t perform that action at this time.
0 commit comments