/// <summary> /// Adds a parameter value to the block. /// </summary> /// <param name="expressionParam">The parameter to add, which has neither been balanced or translated.</param> /// <param name="expectedType">The expected output type of the expression.</param> /// <returns>The current instance, after the parameter has been added.</returns> public BlockBuilder AddParam(IExpression expressionParam, DataType expectedType = DataType.Object) { if (expressionParam == null) { Args.Add(expectedType.GetDefault()); return(this); } DataType valueType = expressionParam.GetReturnType(_context); if (!expectedType.IsCompatible(valueType)) { _context.ErrorList.Add(new CompilerError( $"Expected value of type '{expectedType}' but instead found value of type '{valueType}'", ErrorType.TypeMismatch, expressionParam.ErrorToken, expressionParam.FileName)); } Args.Add(expressionParam.Balance().Translate(_context)); return(this); }