|
@@ -8,9 +8,9 @@ package org.openzen.zenscript.codemodel.expression;
|
8
|
8
|
import java.util.Arrays;
|
9
|
9
|
import org.openzen.zencode.shared.CodePosition;
|
10
|
10
|
import org.openzen.zencode.shared.CompileExceptionCode;
|
11
|
|
-import org.openzen.zenscript.codemodel.FunctionHeader;
|
|
11
|
+import org.openzen.zenscript.codemodel.*;
|
12
|
12
|
import org.openzen.zenscript.codemodel.scope.TypeScope;
|
13
|
|
-import org.openzen.zenscript.codemodel.type.StoredType;
|
|
13
|
+import org.openzen.zenscript.codemodel.type.*;
|
14
|
14
|
|
15
|
15
|
/**
|
16
|
16
|
*
|
|
@@ -64,10 +64,16 @@ public class CallArguments {
|
64
|
64
|
if (arguments.length < header.parameters.length) {
|
65
|
65
|
Expression[] newArguments = Arrays.copyOf(arguments, header.parameters.length);
|
66
|
66
|
for (int i = arguments.length; i < header.parameters.length; i++) {
|
67
|
|
- if (header.parameters[i].defaultValue == null)
|
68
|
|
- newArguments[i] = new InvalidExpression(position, header.parameters[i].type, CompileExceptionCode.MISSING_PARAMETER, "Parameter missing and no default value specified");
|
69
|
|
- else
|
70
|
|
- newArguments[i] = header.parameters[i].defaultValue;
|
|
67
|
+ final FunctionParameter parameter = header.parameters[i];
|
|
68
|
+ if (parameter.defaultValue == null) {
|
|
69
|
+ if(parameter.variadic) {
|
|
70
|
+ newArguments[i] = new ArrayExpression(position, Expression.NONE, parameter.type);
|
|
71
|
+ } else {
|
|
72
|
+ newArguments[i] = new InvalidExpression(position, parameter.type, CompileExceptionCode.MISSING_PARAMETER, "Parameter missing and no default value specified");
|
|
73
|
+ }
|
|
74
|
+ } else {
|
|
75
|
+ newArguments[i] = parameter.defaultValue;
|
|
76
|
+ }
|
71
|
77
|
}
|
72
|
78
|
result = new CallArguments(typeArguments, newArguments);
|
73
|
79
|
}
|