From 22a32c59233e4b963b45ecc428611895b4287afc Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 5 Nov 2024 15:50:40 -0800 Subject: [PATCH] The "normal" tcks now run --- .../src/main/java/org/xvm/xec/XTC.java | 1 + .../xvm/xec/ecstasy/collections/Arylong.java | 3 ++- .../src/main/java/org/xvm/xtc/ast/NewAST.java | 21 +++++++++++++++---- tck/src/main/x/tck.x | 5 +++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/javatools_backend/src/main/java/org/xvm/xec/XTC.java b/javatools_backend/src/main/java/org/xvm/xec/XTC.java index 5aee94688..4f702fd7e 100644 --- a/javatools_backend/src/main/java/org/xvm/xec/XTC.java +++ b/javatools_backend/src/main/java/org/xvm/xec/XTC.java @@ -147,6 +147,7 @@ public static class IllegalState extends Exception { public static class IllegalArgument extends Exception { public IllegalArgument(String s) { super(s); } public static IllegalArgument construct(String s, String cause) { return new IllegalArgument(s); } + public static IllegalArgument construct(String s) { return new IllegalArgument(s); } } // XTC ReadOnlyException mapped to Java diff --git a/javatools_backend/src/main/java/org/xvm/xec/ecstasy/collections/Arylong.java b/javatools_backend/src/main/java/org/xvm/xec/ecstasy/collections/Arylong.java index e1cc03b7e..87cbab5c0 100644 --- a/javatools_backend/src/main/java/org/xvm/xec/ecstasy/collections/Arylong.java +++ b/javatools_backend/src/main/java/org/xvm/xec/ecstasy/collections/Arylong.java @@ -36,7 +36,8 @@ public Arylong( long len, LongUnaryOperator fcn ) { } public static Arylong construct(Mutability mut, Arylong as) { return new Arylong(mut,as); } public static Arylong construct() { return new Arylong(); } - public static Arylong construct( long len, LongUnaryOperator fcn ) { return new Arylong(len,fcn); } + public static Arylong construct(long len, LongUnaryOperator fcn ) { return new Arylong(len,fcn); } + public static Arylong construct(long len, long fill) { return new Arylong((int)len, i->fill ); } public static Arylong construct(long len) { return new Arylong((int)len); } diff --git a/javatools_backend/src/main/java/org/xvm/xtc/ast/NewAST.java b/javatools_backend/src/main/java/org/xvm/xtc/ast/NewAST.java index 529fc4e39..28d477257 100644 --- a/javatools_backend/src/main/java/org/xvm/xtc/ast/NewAST.java +++ b/javatools_backend/src/main/java/org/xvm/xtc/ast/NewAST.java @@ -23,17 +23,30 @@ static NewAST make( ClzBuilder X, boolean isChild ) { AST[] kids = X.kids_bias(isChild ? 1 : 0); if( isChild ) kids[0] = outer; - return new NewAST(kids,(XClz)XType.xtype(type,true),X,type,meth); + return new NewAST(kids,(XClz)XType.xtype(type,true),X,type,meth,isChild); } // For internal constructors like auto-boxing NewAST( AST[] kids, XClz xt ) { - this(kids,xt,null,null,null); + this(kids,xt,null,null,null,false); } - NewAST( AST[] kids, XClz xt, ClzBuilder X, Const type, MethodPart meth ) { + NewAST( AST[] kids, XClz xt, ClzBuilder X, Const type, MethodPart meth, boolean isChild ) { super(kids_plus_clz(kids,xt,X,type)); _type = xt; _meth = meth; - if( meth!=null && kids!=null && meth._args.length != kids.length ) { + + // Replace default args with their actual default values + if( _kids != null ) + for( int i=1; i<_kids.length; i++ ) + if( _kids[i] instanceof RegAST reg && + reg._reg == -4/*Op.A_DEFAULT*/ ) { // Default reg + // Swap in the default from method defaults + TCon con = meth._args[i-1]._def; + _kids[i] = con==null + ? new ConAST("0",meth.xfun().arg(i)) + : new ConAST(null,con); + } + + if( meth!=null && kids!=null && (meth._args==null?0:meth._args.length)+(isChild?1:0) != kids.length ) { int len = kids.length; assert len+1==meth._args.length; // more default args _kids = Arrays.copyOf(_kids,meth._args.length); diff --git a/tck/src/main/x/tck.x b/tck/src/main/x/tck.x index 6fb65e25a..1b8b2de1a 100644 --- a/tck/src/main/x/tck.x +++ b/tck/src/main/x/tck.x @@ -1,7 +1,7 @@ module tck.xtclang.org { /** - * This is temporary, for manual testing only; will be replaced by the xUint framework. + * This is temporary, for manual testing only; will be replaced by the xUnit framework. */ void run() { new clazz.Basic().run(); @@ -15,9 +15,10 @@ module tck.xtclang.org { new operations.Basic().run(); new tuples.Basic().run(); new tuples.MultiReturn().run(); - //new services.Basic().run(); + new time.Basic().run(); new constructors.Basic().run(); new union.Basic().run(); + new services.Basic().run(); //new clazz.Medium().run(); //new array.Medium().run();