예제 #1
0
        private void ResolveFrameworkMethodReference(ResolvedType[] argTypes)
        {
            ResolvedType resolvedType = this.RootValue.ResolvedType;

            if (resolvedType.IsEnum)
            {
                if (resolvedType.FrameworkClass != null)
                {
                    if (!resolvedType.HasEnumField(this.Name.Value))
                    {
                        throw new ParserException(
                                  this.Name,
                                  resolvedType.ToString() + " doesn't have a field called " + this.Name.Value);
                    }
                    this.ResolvedType = ResolvedType.CreateEnumField(resolvedType);
                }
                else
                {
                    throw new NotImplementedException();
                }
                return;
            }
            string className  = resolvedType.FrameworkClass;
            string methodName = this.Name.Value;

            this.Type = MethodRefType.FRAMEWORK_METHOD;
            switch (className + ":" + methodName)
            {
            case "System.Collections.Generic.HashSet:Contains":
            case "System.Collections.Generic.ISet:Contains":
                ResolvedType itemType = resolvedType.Generics[0];
                this.ResolvedType = ResolvedType.CreateFunction(ResolvedType.Bool(), new ResolvedType[] { itemType });
                return;

            case "System.Collections.Generic.Dictionary:Keys":
            case "System.Collections.Generic.IDictionary:Keys":
                ResolvedType keyType = resolvedType.Generics[0];
                this.ResolvedType = ResolvedType.CreateEnumerableType(keyType);
                return;

            case "System.Collections.Generic.Dictionary:Values":
            case "System.Collections.Generic.IDictionary:Values":
                ResolvedType valueType = resolvedType.Generics[1];
                this.ResolvedType = ResolvedType.CreateEnumerableType(valueType);
                return;

            case "CommonUtil.Collections.Pair:First":
                this.ResolvedType = resolvedType.Generics[0];
                break;

            case "CommonUtil.Collections.Pair:Second":
                this.ResolvedType = resolvedType.Generics[1];
                break;

            case "CommonUtil.DateTime.Time:UnixTimeNow":
            case "System.Collections.Generic.HashSet:Count":
            case "System.Collections.Generic.Dictionary:Count":
            case "System.Collections.Generic.IDictionary:Count":
                this.ResolvedType = ResolvedType.Int();
                return;

            default:
                throw new ParserException(this.FirstToken, "Not implemented --> " + className + ":" + methodName);
            }
        }