/// <summary> /// Gets the display name. /// </summary> public override string GetDisplayName() { if (displayName == null) { StringBuilder builder = new StringBuilder(); builder.Append(returnType.GetDisplayName()); builder.Append("("); int numargs = arguments.Length; for (int i = 0; i < numargs; i++) { if (i > 0) { builder.Append(", "); } if (IsVariable() && i + 1 == numargs) { builder.Append("params "); } IChelaType arg = arguments[i]; builder.Append(arg.GetDisplayName()); } builder.Append(")"); displayName = builder.ToString(); } return(displayName); }
/// <summary> /// Gets the display name. /// </summary> public override string GetDisplayName() { if (displayName == null) { displayName = pointedType.GetDisplayName() + "*"; } return(displayName); }
/// <summary> /// Array type display name. /// </summary> public override string GetDisplayName() { if (displayName == null) { if (readOnly) { displayName = "readonly "; } displayName += valueType.GetDisplayName() + "["; for (int i = 1; i < dimensions; ++i) { displayName += ","; } displayName += "]"; } return(displayName); }
/// <summary> /// Gets the display name. /// </summary> public override string GetDisplayName() { if (referencedType == null) { return("null"); } if (displayName == null) { switch (referenceFlow) { case ReferenceFlow.In: displayName = "in "; break; case ReferenceFlow.Out: displayName = "out "; break; case ReferenceFlow.InOut: default: if (referencedType.IsPassedByReference()) { displayName = ""; } else { displayName = "ref "; } break; } displayName += referencedType.GetDisplayName(); } return(displayName); }
public override string GetDisplayName() { return("typename " + actualType.GetDisplayName()); }
private void CheckArrayInitializers(AstNode where, int[] sizes, int depth, IChelaType coercionType, AstNode initializers) { // Common variables during the iteration. AstNode current = initializers; int size = sizes[depth]; int currentIndex = 0; bool array = depth + 1 < sizes.Length; // Check each one of the array initializers. while(current != null) { // Don't get pass of the size. if(size >= 0 && currentIndex == size) Error(current, "unexpected extra element in a dimension."); // Increase the depth if the node is an array. if(current is ArrayExpression) { // Make sure an array its expected. if(!array) Error(current, "expected an expression, not a sub-array."); // Process the sub-array. ArrayExpression arrayExpr = (ArrayExpression)current; CheckArrayInitializers(current, sizes, depth+1, coercionType, arrayExpr.GetElements()); } else { // Make sure an expression its expected. if(array) Error(current, "expected a sub-aray, not an expression."); // Visit the expression. current.Accept(this); // Perform his coercion. IChelaType currentType = current.GetNodeType(); if(currentType != coercionType && Coerce(current, coercionType, currentType, current.GetNodeValue()) != coercionType) Error(current, "cannot perform implicit cast {0} -> {1}.", currentType.GetDisplayName(), coercionType.GetDisplayName()); } // Process the next expression/array. ++currentIndex; current = current.GetNext(); } // Make sure the aren't fewer elements. if(size >= 0) { if(currentIndex < size) Error(where, "fewer elements than expected."); } else { // Update the size. sizes[depth] = currentIndex; } // Make sure there's at least one element when depth > 0. if(depth > 0 && currentIndex == 0) Error(where, "expected at least one element."); }