public GrapeMethod(GrapeList<GrapeModifier> modifiers, GrapeType returnType, GrapeIdentifier name, GrapeList<GrapeParameter> parameters, GrapeList<GrapeStatement> body) : base(modifiers) { this.returnType = returnType; this.name = name.Name; this.parameters = parameters.ToList(this).AsReadOnly(); this.body = body.ToList(this).AsReadOnly(); }
public GrapeArrayType(GrapeType elementType): base() { this.elementType = elementType; }
public GrapeTypecastExpression(GrapeExpression value, GrapeType typeName) { this.value = value; this.typeName = typeName; }
public GrapeVariable(GrapeType type, GrapeIdentifier name) : this(type, name, null) { }
public GrapeVariable(GrapeType type, GrapeIdentifier name, GrapeInitializer initializer) { this.name = name.Name; this.type = type; this.initializer = initializer; }
public string GetTypeNameForTypeAccessExpression(GrapeCodeGeneratorConfiguration config, GrapeType type, ref string errorMessage) { // left for compat return type.ToString(); }
public GrapeParameter(GrapeType type, GrapeIdentifier name) : base(type, name, null) { }
public List<GrapeMethod> GetMethodsWithSignature(GrapeCodeGeneratorConfiguration config, List<GrapeMethod> methods, GrapeModifier.GrapeModifierType modifiers, string name, GrapeType returnType, List<GrapeVariable> parameters, ref string errorMessage) { List<GrapeMethod> foundMethods = new List<GrapeMethod>(); string parameterErrorMessage = ""; foreach (GrapeMethod method in methods) { if (method.Name == name && GetTypeNameForTypeAccessExpression(config, method.ReturnType) == GetTypeNameForTypeAccessExpression(config, returnType) && method.Parameters.Count == parameters.Count) { if (modifiers != 0) { bool shouldContinue = false; if (modifiers != method.Modifiers) { shouldContinue = true; } if (shouldContinue) { continue; } } int currentParameterIndex = 0; bool validParameters = true; foreach (GrapeVariable param in method.Parameters) { GrapeVariable currentParameter = parameters[currentParameterIndex]; if (!DoesExpressionResolveToType(config, currentParameter, currentParameter.Type, param.Type, ref parameterErrorMessage)) { validParameters = false; if (parameterErrorMessage == "") { parameterErrorMessage = "Cannot resolve parameter type '" + GetTypeNameForTypeAccessExpression(config, currentParameter.Type) + "' to type '" + GetTypeNameForTypeAccessExpression(config, param.Type) + "'."; } break; } currentParameterIndex++; } if (validParameters) { foundMethods.Add(method); } } } if (foundMethods.Count == 0) { errorMessage = "Cannot find method with signature '" + GetMethodSignatureString(config, name, returnType, parameters) + "'. " + parameterErrorMessage; } return foundMethods; }
public string GetTypeNameForTypeAccessExpression(GrapeCodeGeneratorConfiguration config, GrapeType type) { // left for compat string dummyMessage = ""; return GetTypeNameForTypeAccessExpression(config, type, ref dummyMessage); }
public string GetMethodSignatureString(GrapeCodeGeneratorConfiguration config, string name, GrapeType returnType, List<GrapeVariable> parameters) { string result = GetTypeNameForTypeAccessExpression(config, returnType) + " " + name + "("; int index = 0; foreach (GrapeVariable parameter in parameters) { result += GetTypeNameForTypeAccessExpression(config, parameter.Type); if (index < parameters.Count - 1) { result += ", "; } index++; } result += ")"; return result; }
public bool DoesExpressionResolveToType(GrapeCodeGeneratorConfiguration config, GrapeEntity parent, GrapeType expression, string typeName, ref string errorMessage) { // left for compat return expression.ToString() == typeName; }
public bool DoesExpressionResolveToType(GrapeCodeGeneratorConfiguration config, GrapeEntity parent, GrapeExpression expression, GrapeType type, ref string errorMessage) { // left for compat return DoesExpressionResolveToType(config, parent, expression, type.ToString(), ref errorMessage); }
public bool DoesExpressionResolveToType(GrapeCodeGeneratorConfiguration config, GrapeEntity parent, GrapeExpression expression, GrapeType type) { // left for compat string dummyMessage = ""; return DoesExpressionResolveToType(config, parent, expression, type, ref dummyMessage); }
public bool DoesExpressionResolveToType(GrapeCodeGeneratorConfiguration config, GrapeEntity parent, GrapeType expression, GrapeType type) { // left for compat return expression.ToString() == type.ToString(); }
public IEnumerable<GrapeEntity> GetEntitiesForAccessExpression(GrapeCodeGeneratorConfiguration config, GrapeType type, GrapeEntity parent, out string errorMessage, bool detectMethodsUsedAsTypesOrVars) { // left for compat errorMessage = ""; return GetClassesForExpression(config, type.ToString(), parent); }
public bool DoesTypeExist(GrapeCodeGeneratorConfiguration config, GrapeType type, string fileName) { string dummyMessage = ""; return DoesTypeExist(config, GetTypeNameForTypeAccessExpression(config, type, ref dummyMessage), fileName); }