public Expression[] GetExpTypeWithHashTable( PackagesContext packagesContext, IContext expContext, GenericityType prefixType, Expression indexValue) { if (indexValue.Type != prefixType.FirstGroupGenericTypeArguments[0] || indexValue.Classify != ExpressionType.Value) { throw new SyntaxException("Cannot resolve symbol here.", this.Lbracket.Line, this.Lbracket.Column); } return(this.GetExpressionsWithValue(prefixType.FirstGroupGenericTypeArguments[1])); }
public override void ContextVerify(IContext context) { //形参 GenericityType prefixType = this.GetPrefixType(context.ClassContext.Packages, context); var argumentTypes = prefixType.SecondGroupGenericTypeArguments; int argumentCount = 0; if (argumentTypes.Length == 0 || (argumentTypes.Length == 1 && argumentTypes[0] == Type.Void)) { argumentCount = 0; } else { argumentCount = argumentTypes.Length; } //实参 var paramExpList = this.Argumentlist.Symbol.GetArguments(new List <Token <Exp_basisproduction> >()); List <Expression> paramList = new List <Expression>(); for (int i = 0; i < paramExpList.Count; i++) { var paramExp = paramExpList[i]; var paramValue = paramExp.Symbol.GetExpressions(context.ClassContext.Packages, context); if (paramValue.Length == 0 || (paramValue.Length == 1 && paramValue[0].Type == Type.Void)) { throw new SyntaxException(string.Format("Argument {0}:Cannot use non-value expression here.", i + 1), Lparen.Line, Lparen.Column); } paramList.AddRange(paramValue); } //跳过Any类型的匹配检测 if (prefixType == GenericityType.Any) { return; } //数量判断 if (argumentCount != paramList.Count) { throw new SyntaxException(string.Format("The function has {0} parameter but is invoked with {1}", argumentCount, paramExpList.Count), this.Lparen.Line, this.Lparen.Column); } //类型判断 for (int i = 0; i < argumentCount; i++) { var argumentType = argumentTypes[i]; var paramType = paramList[i].Type; //函数类返回值确定 if (paramType.Name == Type.Function.Name && paramType.PackageName == Type.Function.PackageName && argumentType.Name == Type.Function.Name && argumentType.PackageName == Type.Function.PackageName) { var pGenericityType = paramType as GenericityType; var aGenericityType = argumentType as GenericityType; if (pGenericityType.FirstGroupGenericTypeArguments == null) { pGenericityType.FirstGroupGenericTypeArguments = aGenericityType.FirstGroupGenericTypeArguments; } } //类型匹配 if (!argumentType.IsAssignableFrom(paramType)) { throw new SyntaxException(string.Format("Argument {0}: cannot convert from '{1}' to '{2}'.", i + 1, paramType.FullName, argumentType.FullName), Lparen.Line, Lparen.Column); } } //参数上下文合法性检测 for (int i = 0; i < paramExpList.Count; i++) { var paramExp = paramExpList[i]; paramExp.Symbol.ContextVerify(context); } }
protected override Type[] OnGetReturnValues(PackagesContext packagesContext, IContext expContext) { GenericityType prefixType = this.GetPrefixType(packagesContext, expContext); return(prefixType.FirstGroupGenericTypeArguments); }