private void AddParameters(Oberon0ExportAttribute attr, int i, IList <ProcedureParameterDeclaration> procParameters) { string paramName = "attr" + i; procParameters[i] = GetProcedureParameterByName(paramName, attr.Parameters[i], Block); }
/// <summary> /// Add external function declaration /// </summary> /// <param name="attr">The <see cref="Oberon0ExportAttribute" /> structure</param> /// <param name="className">The providing class</param> /// <param name="methodName">The method name</param> /// <returns>an <see cref="ExternalFunctionDeclaration " /> representing the function</returns> // ReSharper disable once MemberCanBePrivate.Global internal ExternalFunctionDeclaration AddExternalFunctionDeclaration([NotNull] Oberon0ExportAttribute attr, [NotNull] string className, [NotNull] string methodName) { if (attr == null) { throw new ArgumentNullException(nameof(attr)); } if (className == null) { throw new ArgumentNullException(nameof(className)); } if (methodName == null) { throw new ArgumentNullException(nameof(methodName)); } var rt = Block.LookupType(attr.ReturnType); if (rt == null) { throw new InvalidOperationException($"Return type {attr.ReturnType} not defined"); } var procParameters = new ProcedureParameterDeclaration[attr.Parameters.Length]; for (int i = 0; i < attr.Parameters.Length; i++) { AddParameters(attr, i, procParameters); } return(new ExternalFunctionDeclaration(attr.Name, new Block(Block, this), rt, className, methodName, procParameters)); }