+ Expression[] parameters = translateFieldsToFunctionParameters(context, fields, fieldNames);
+ if(parameters == null)
+ return new EError(location);
+ if(asPattern)
+ for(int i=0;i<parameters.length;++i) {
+ Expression parameter = parameters[i];
+ if(parameter == null)
+ parameters[i] = Expressions.blank(null);
+ else
+ parameters[i] = parameter.resolveAsPattern(context);
+ }
+ else {
+ boolean error = false;
+ for(int i=0;i<parameters.length;++i) {
+ Expression parameter = parameters[i];
+ if(parameter == null) {
+ ExistentialFrame frame = context.getCurrentExistentialFrame();
+ if(frame == null || frame.disallowNewExistentials) {
+ context.getErrorLog().log(location, "Field " + fieldNames[i] + " not defined.");
+ error = true;
+ }
+ else
+ parameters[i] = frame.createBlank(location);
+ }
+ else
+ parameters[i] = parameter.resolve(context);
+ }
+ if(error)
+ return new EError(location);
+ }
+ EApply result = new EApply(new EConstant(constructorValue), parameters);
+ result.setLocationDeep(location);
+ return result;
+ }
+
+ public static Expression[] translateFieldsToFunctionParameters(TranslationContext context, FieldAssignment[] fields, String[] fieldNames) {