Exemplo n.º 1
0
 public UnaOpSig(PredefinedType pt, UnaOpMask grfuom, int cuosSkip, PfnBindUnaOp pfn, UnaOpFuncKind fnkind)
 {
     this.pt = pt;
     this.grfuom = grfuom;
     this.cuosSkip = cuosSkip;
     this.pfn = pfn;
     this.fnkind = fnkind;
 }
Exemplo n.º 2
0
        internal static AggregateSymbol InitializePredefinedType(AggregateSymbol sym, PredefinedType pt)
        {
            sym.SetPredefined(true);
            sym.SetPredefType(pt);
            sym.SetSkipUDOps(pt <= PredefinedType.PT_ENUM && pt != PredefinedType.PT_INTPTR && pt != PredefinedType.PT_UINTPTR && pt != PredefinedType.PT_TYPE);

            return sym;
        }
Exemplo n.º 3
0
 public BinOpSig(PredefinedType pt1, PredefinedType pt2,
     BinOpMask mask, int cbosSkip, PfnBindBinOp pfn, OpSigFlags grfos, BinOpFuncKind fnkind)
 {
     this.pt1 = pt1;
     this.pt2 = pt2;
     this.mask = mask;
     this.cbosSkip = cbosSkip;
     this.pfn = pfn;
     this.grfos = grfos;
     this.fnkind = fnkind;
 }
Exemplo n.º 4
0
        // We want to delay load the predef syms as needed.
        private AggregateSymbol DelayLoadPredefSym(PredefinedType pt)
        {
            CType type = _runtimeBinderSymbolTable.GetCTypeFromType(PredefinedTypeFacts.GetAssociatedSystemType(pt));
            AggregateSymbol sym = type.getAggregate();

            // If we failed to load this thing, we have problems.
            if (sym == null)
            {
                return null;
            }
            return PredefinedTypes.InitializePredefinedType(sym, pt);
        }
Exemplo n.º 5
0
 public bool isPredefAgg(PredefinedType pt)
 {
     return _isPredefined && (PredefinedType)_iPredef == pt;
 }
Exemplo n.º 6
0
 internal PredefinedTypeInfo(PredefinedType type, Type associatedSystemType, string name, bool required, int arity, bool inMscorlib)
     : this(type, associatedSystemType, name, required, arity, AggKindEnum.Class, FUNDTYPE.FT_REF, inMscorlib)
 {
 }
Exemplo n.º 7
0
 protected virtual EXPRARRINIT GenerateParamsArray(EXPR args, PredefinedType pt)
 {
     int parameterCount = ExpressionIterator.Count(args);
     AggregateType paramsArrayElementType = GetSymbolLoader().GetOptPredefTypeErr(pt, true);
     ArrayType paramsArrayType = GetSymbolLoader().GetTypeManager().GetArray(paramsArrayElementType, 1);
     EXPRCONSTANT paramsArrayArg = GetExprFactory().CreateIntegerConstant(parameterCount);
     EXPRARRINIT arrayInit = GetExprFactory().CreateArrayInit(EXPRFLAG.EXF_CANTBENULL, paramsArrayType, args, paramsArrayArg, null);
     arrayInit.dimSize = parameterCount;
     arrayInit.dimSizes = new int[] { arrayInit.dimSize }; // CLEANUP: Why isn't this done by the factory?
     return arrayInit;
 }
Exemplo n.º 8
0
 public override bool IsPredefType(PredefinedType pt) => pt == PredefinedType.PT_VOID;
Exemplo n.º 9
0
 internal PredefinedTypeInfo(PredefinedType type, Type associatedSystemType, string name, bool required, int arity, AggKindEnum aggKind, FUNDTYPE fundType, bool inMscorlib)
 {
     this.type = type;
     this.name = name;
     this.required = required;
     this.fundType = fundType;
     this.AssociatedSystemType = associatedSystemType;
 }
Exemplo n.º 10
0
 internal static FUNDTYPE GetFundType(PredefinedType type)
 {
     return s_pdTypes[(int)type].fundType;
 }
Exemplo n.º 11
0
 public static string GetFullName(PredefinedType pt)
 {
     return PredefinedTypeFacts.GetName(pt);
 }
Exemplo n.º 12
0
        public static Doc Print(SyntaxNode syntaxNode)
        {
            if (syntaxNode == null)
            {
                return(Doc.Null);
            }

            // TODO 0 kill? runtime repo has files that will fail on deep recursion
            if (depth > 200)
            {
                throw new InTooDeepException();
            }

            depth++;
            try
            {
                switch (syntaxNode)
                {
                case AliasQualifiedNameSyntax aliasQualifiedNameSyntax:
                    return(AliasQualifiedName.Print(aliasQualifiedNameSyntax));

                case AnonymousMethodExpressionSyntax anonymousMethodExpressionSyntax:
                    return(AnonymousMethodExpression.Print(anonymousMethodExpressionSyntax));

                case AnonymousObjectCreationExpressionSyntax anonymousObjectCreationExpressionSyntax:
                    return(AnonymousObjectCreationExpression.Print(
                               anonymousObjectCreationExpressionSyntax
                               ));

                case AnonymousObjectMemberDeclaratorSyntax anonymousObjectMemberDeclaratorSyntax:
                    return(AnonymousObjectMemberDeclarator.Print(
                               anonymousObjectMemberDeclaratorSyntax
                               ));

                case ArgumentListSyntax argumentListSyntax:
                    return(ArgumentList.Print(argumentListSyntax));

                case ArgumentSyntax argumentSyntax:
                    return(Argument.Print(argumentSyntax));

                case ArrayCreationExpressionSyntax arrayCreationExpressionSyntax:
                    return(ArrayCreationExpression.Print(arrayCreationExpressionSyntax));

                case ArrayRankSpecifierSyntax arrayRankSpecifierSyntax:
                    return(ArrayRankSpecifier.Print(arrayRankSpecifierSyntax));

                case ArrayTypeSyntax arrayTypeSyntax:
                    return(ArrayType.Print(arrayTypeSyntax));

                case ArrowExpressionClauseSyntax arrowExpressionClauseSyntax:
                    return(ArrowExpressionClause.Print(arrowExpressionClauseSyntax));

                case AssignmentExpressionSyntax assignmentExpressionSyntax:
                    return(AssignmentExpression.Print(assignmentExpressionSyntax));

                case AttributeListSyntax attributeListSyntax:
                    return(AttributeList.Print(attributeListSyntax));

                case AwaitExpressionSyntax awaitExpressionSyntax:
                    return(AwaitExpression.Print(awaitExpressionSyntax));

                case BaseExpressionSyntax baseExpressionSyntax:
                    return(BaseExpression.Print(baseExpressionSyntax));

                case BaseFieldDeclarationSyntax baseFieldDeclarationSyntax:
                    return(BaseFieldDeclaration.Print(baseFieldDeclarationSyntax));

                case BaseListSyntax baseListSyntax:
                    return(BaseList.Print(baseListSyntax));

                case BaseMethodDeclarationSyntax baseMethodDeclarationSyntax:
                    return(BaseMethodDeclaration.Print(baseMethodDeclarationSyntax));

                case BasePropertyDeclarationSyntax basePropertyDeclarationSyntax:
                    return(BasePropertyDeclaration.Print(basePropertyDeclarationSyntax));

                case BaseTypeDeclarationSyntax baseTypeDeclarationSyntax:
                    return(BaseTypeDeclaration.Print(baseTypeDeclarationSyntax));

                case BinaryExpressionSyntax binaryExpressionSyntax:
                    return(BinaryExpression.Print(binaryExpressionSyntax));

                case BinaryPatternSyntax binaryPatternSyntax:
                    return(BinaryPattern.Print(binaryPatternSyntax));

                case BlockSyntax blockSyntax:
                    return(Block.Print(blockSyntax));

                case BracketedArgumentListSyntax bracketedArgumentListSyntax:
                    return(BracketedArgumentList.Print(bracketedArgumentListSyntax));

                case BracketedParameterListSyntax bracketedParameterListSyntax:
                    return(BracketedParameterList.Print(bracketedParameterListSyntax));

                case BreakStatementSyntax breakStatementSyntax:
                    return(BreakStatement.Print(breakStatementSyntax));

                case CasePatternSwitchLabelSyntax casePatternSwitchLabelSyntax:
                    return(CasePatternSwitchLabel.Print(casePatternSwitchLabelSyntax));

                case CaseSwitchLabelSyntax caseSwitchLabelSyntax:
                    return(CaseSwitchLabel.Print(caseSwitchLabelSyntax));

                case CastExpressionSyntax castExpressionSyntax:
                    return(CastExpression.Print(castExpressionSyntax));

                case CatchClauseSyntax catchClauseSyntax:
                    return(CatchClause.Print(catchClauseSyntax));

                case CheckedExpressionSyntax checkedExpressionSyntax:
                    return(CheckedExpression.Print(checkedExpressionSyntax));

                case CheckedStatementSyntax checkedStatementSyntax:
                    return(CheckedStatement.Print(checkedStatementSyntax));

                case ClassOrStructConstraintSyntax classOrStructConstraintSyntax:
                    return(ClassOrStructConstraint.Print(classOrStructConstraintSyntax));

                case CompilationUnitSyntax compilationUnitSyntax:
                    return(CompilationUnit.Print(compilationUnitSyntax));

                case ConditionalAccessExpressionSyntax conditionalAccessExpressionSyntax:
                    return(ConditionalAccessExpression.Print(conditionalAccessExpressionSyntax));

                case ConditionalExpressionSyntax conditionalExpressionSyntax:
                    return(ConditionalExpression.Print(conditionalExpressionSyntax));

                case ConstantPatternSyntax constantPatternSyntax:
                    return(ConstantPattern.Print(constantPatternSyntax));

                case ConstructorConstraintSyntax constructorConstraintSyntax:
                    return(ConstructorConstraint.Print(constructorConstraintSyntax));

                case ConstructorInitializerSyntax constructorInitializerSyntax:
                    return(ConstructorInitializer.Print(constructorInitializerSyntax));

                case ContinueStatementSyntax continueStatementSyntax:
                    return(ContinueStatement.Print(continueStatementSyntax));

                case DeclarationExpressionSyntax declarationExpressionSyntax:
                    return(DeclarationExpression.Print(declarationExpressionSyntax));

                case DeclarationPatternSyntax declarationPatternSyntax:
                    return(DeclarationPattern.Print(declarationPatternSyntax));

                case DefaultConstraintSyntax defaultConstraintSyntax:
                    return(DefaultConstraint.Print(defaultConstraintSyntax));

                case DefaultExpressionSyntax defaultExpressionSyntax:
                    return(DefaultExpression.Print(defaultExpressionSyntax));

                case DefaultSwitchLabelSyntax defaultSwitchLabelSyntax:
                    return(DefaultSwitchLabel.Print(defaultSwitchLabelSyntax));

                case DelegateDeclarationSyntax delegateDeclarationSyntax:
                    return(DelegateDeclaration.Print(delegateDeclarationSyntax));

                case DiscardDesignationSyntax discardDesignationSyntax:
                    return(DiscardDesignation.Print(discardDesignationSyntax));

                case DiscardPatternSyntax discardPatternSyntax:
                    return(DiscardPattern.Print(discardPatternSyntax));

                case DoStatementSyntax doStatementSyntax:
                    return(DoStatement.Print(doStatementSyntax));

                case ElementAccessExpressionSyntax elementAccessExpressionSyntax:
                    return(ElementAccessExpression.Print(elementAccessExpressionSyntax));

                case ElementBindingExpressionSyntax elementBindingExpressionSyntax:
                    return(ElementBindingExpression.Print(elementBindingExpressionSyntax));

                case ElseClauseSyntax elseClauseSyntax:
                    return(ElseClause.Print(elseClauseSyntax));

                case EmptyStatementSyntax emptyStatementSyntax:
                    return(EmptyStatement.Print(emptyStatementSyntax));

                case EnumMemberDeclarationSyntax enumMemberDeclarationSyntax:
                    return(EnumMemberDeclaration.Print(enumMemberDeclarationSyntax));

                case EqualsValueClauseSyntax equalsValueClauseSyntax:
                    return(EqualsValueClause.Print(equalsValueClauseSyntax));

                case ExpressionStatementSyntax expressionStatementSyntax:
                    return(ExpressionStatement.Print(expressionStatementSyntax));

                case ExternAliasDirectiveSyntax externAliasDirectiveSyntax:
                    return(ExternAliasDirective.Print(externAliasDirectiveSyntax));

                case FinallyClauseSyntax finallyClauseSyntax:
                    return(FinallyClause.Print(finallyClauseSyntax));

                case FixedStatementSyntax fixedStatementSyntax:
                    return(FixedStatement.Print(fixedStatementSyntax));

                case ForEachStatementSyntax forEachStatementSyntax:
                    return(ForEachStatement.Print(forEachStatementSyntax));

                case ForEachVariableStatementSyntax forEachVariableStatementSyntax:
                    return(ForEachVariableStatement.Print(forEachVariableStatementSyntax));

                case ForStatementSyntax forStatementSyntax:
                    return(ForStatement.Print(forStatementSyntax));

                case FromClauseSyntax fromClauseSyntax:
                    return(FromClause.Print(fromClauseSyntax));

                case FunctionPointerTypeSyntax functionPointerTypeSyntax:
                    return(FunctionPointerType.Print(functionPointerTypeSyntax));

                case GenericNameSyntax genericNameSyntax:
                    return(GenericName.Print(genericNameSyntax));

                case GlobalStatementSyntax globalStatementSyntax:
                    return(GlobalStatement.Print(globalStatementSyntax));

                case GotoStatementSyntax gotoStatementSyntax:
                    return(GotoStatement.Print(gotoStatementSyntax));

                case GroupClauseSyntax groupClauseSyntax:
                    return(GroupClause.Print(groupClauseSyntax));

                case IdentifierNameSyntax identifierNameSyntax:
                    return(IdentifierName.Print(identifierNameSyntax));

                case IfStatementSyntax ifStatementSyntax:
                    return(IfStatement.Print(ifStatementSyntax));

                case ImplicitArrayCreationExpressionSyntax implicitArrayCreationExpressionSyntax:
                    return(ImplicitArrayCreationExpression.Print(
                               implicitArrayCreationExpressionSyntax
                               ));

                case ImplicitElementAccessSyntax implicitElementAccessSyntax:
                    return(ImplicitElementAccess.Print(implicitElementAccessSyntax));

                case ImplicitObjectCreationExpressionSyntax implicitObjectCreationExpressionSyntax:
                    return(ImplicitObjectCreationExpression.Print(
                               implicitObjectCreationExpressionSyntax
                               ));

                case ImplicitStackAllocArrayCreationExpressionSyntax implicitStackAllocArrayCreationExpressionSyntax:
                    return(ImplicitStackAllocArrayCreationExpression.Print(
                               implicitStackAllocArrayCreationExpressionSyntax
                               ));

                case IncompleteMemberSyntax incompleteMemberSyntax:
                    return(IncompleteMember.Print(incompleteMemberSyntax));

                case InitializerExpressionSyntax initializerExpressionSyntax:
                    return(InitializerExpression.Print(initializerExpressionSyntax));

                case InterpolatedStringExpressionSyntax interpolatedStringExpressionSyntax:
                    return(InterpolatedStringExpression.Print(
                               interpolatedStringExpressionSyntax
                               ));

                case InterpolatedStringTextSyntax interpolatedStringTextSyntax:
                    return(InterpolatedStringText.Print(interpolatedStringTextSyntax));

                case InterpolationSyntax interpolationSyntax:
                    return(Interpolation.Print(interpolationSyntax));

                case InvocationExpressionSyntax invocationExpressionSyntax:
                    return(InvocationExpression.Print(invocationExpressionSyntax));

                case IsPatternExpressionSyntax isPatternExpressionSyntax:
                    return(IsPatternExpression.Print(isPatternExpressionSyntax));

                case JoinClauseSyntax joinClauseSyntax:
                    return(JoinClause.Print(joinClauseSyntax));

                case LabeledStatementSyntax labeledStatementSyntax:
                    return(LabeledStatement.Print(labeledStatementSyntax));

                case LetClauseSyntax letClauseSyntax:
                    return(LetClause.Print(letClauseSyntax));

                case LiteralExpressionSyntax literalExpressionSyntax:
                    return(LiteralExpression.Print(literalExpressionSyntax));

                case LocalDeclarationStatementSyntax localDeclarationStatementSyntax:
                    return(LocalDeclarationStatement.Print(localDeclarationStatementSyntax));

                case LocalFunctionStatementSyntax localFunctionStatementSyntax:
                    return(LocalFunctionStatement.Print(localFunctionStatementSyntax));

                case LockStatementSyntax lockStatementSyntax:
                    return(LockStatement.Print(lockStatementSyntax));

                case MakeRefExpressionSyntax makeRefExpressionSyntax:
                    return(MakeRefExpression.Print(makeRefExpressionSyntax));

                case MemberAccessExpressionSyntax memberAccessExpressionSyntax:
                    return(MemberAccessExpression.Print(memberAccessExpressionSyntax));

                case MemberBindingExpressionSyntax memberBindingExpressionSyntax:
                    return(MemberBindingExpression.Print(memberBindingExpressionSyntax));

                case NameColonSyntax nameColonSyntax:
                    return(NameColon.Print(nameColonSyntax));

                case NameEqualsSyntax nameEqualsSyntax:
                    return(NameEquals.Print(nameEqualsSyntax));

                case NamespaceDeclarationSyntax namespaceDeclarationSyntax:
                    return(NamespaceDeclaration.Print(namespaceDeclarationSyntax));

                case NullableTypeSyntax nullableTypeSyntax:
                    return(NullableType.Print(nullableTypeSyntax));

                case ObjectCreationExpressionSyntax objectCreationExpressionSyntax:
                    return(ObjectCreationExpression.Print(objectCreationExpressionSyntax));

                case OmittedArraySizeExpressionSyntax omittedArraySizeExpressionSyntax:
                    return(OmittedArraySizeExpression.Print(omittedArraySizeExpressionSyntax));

                case OmittedTypeArgumentSyntax omittedTypeArgumentSyntax:
                    return(OmittedTypeArgument.Print(omittedTypeArgumentSyntax));

                case OrderByClauseSyntax orderByClauseSyntax:
                    return(OrderByClause.Print(orderByClauseSyntax));

                case ParameterListSyntax parameterListSyntax:
                    return(ParameterList.Print(parameterListSyntax));

                case ParameterSyntax parameterSyntax:
                    return(Parameter.Print(parameterSyntax));

                case ParenthesizedExpressionSyntax parenthesizedExpressionSyntax:
                    return(ParenthesizedExpression.Print(parenthesizedExpressionSyntax));

                case ParenthesizedLambdaExpressionSyntax parenthesizedLambdaExpressionSyntax:
                    return(ParenthesizedLambdaExpression.Print(
                               parenthesizedLambdaExpressionSyntax
                               ));

                case ParenthesizedPatternSyntax parenthesizedPatternSyntax:
                    return(ParenthesizedPattern.Print(parenthesizedPatternSyntax));

                case ParenthesizedVariableDesignationSyntax parenthesizedVariableDesignationSyntax:
                    return(ParenthesizedVariableDesignation.Print(
                               parenthesizedVariableDesignationSyntax
                               ));

                case PointerTypeSyntax pointerTypeSyntax:
                    return(PointerType.Print(pointerTypeSyntax));

                case PostfixUnaryExpressionSyntax postfixUnaryExpressionSyntax:
                    return(PostfixUnaryExpression.Print(postfixUnaryExpressionSyntax));

                case PredefinedTypeSyntax predefinedTypeSyntax:
                    return(PredefinedType.Print(predefinedTypeSyntax));

                case PrefixUnaryExpressionSyntax prefixUnaryExpressionSyntax:
                    return(PrefixUnaryExpression.Print(prefixUnaryExpressionSyntax));

                case PrimaryConstructorBaseTypeSyntax primaryConstructorBaseTypeSyntax:
                    return(PrimaryConstructorBaseType.Print(primaryConstructorBaseTypeSyntax));

                case QualifiedNameSyntax qualifiedNameSyntax:
                    return(QualifiedName.Print(qualifiedNameSyntax));

                case QueryBodySyntax queryBodySyntax:
                    return(QueryBody.Print(queryBodySyntax));

                case QueryContinuationSyntax queryContinuationSyntax:
                    return(QueryContinuation.Print(queryContinuationSyntax));

                case QueryExpressionSyntax queryExpressionSyntax:
                    return(QueryExpression.Print(queryExpressionSyntax));

                case RangeExpressionSyntax rangeExpressionSyntax:
                    return(RangeExpression.Print(rangeExpressionSyntax));

                case RecursivePatternSyntax recursivePatternSyntax:
                    return(RecursivePattern.Print(recursivePatternSyntax));

                case RefExpressionSyntax refExpressionSyntax:
                    return(RefExpression.Print(refExpressionSyntax));

                case RefTypeExpressionSyntax refTypeExpressionSyntax:
                    return(RefTypeExpression.Print(refTypeExpressionSyntax));

                case RefTypeSyntax refTypeSyntax:
                    return(RefType.Print(refTypeSyntax));

                case RefValueExpressionSyntax refValueExpressionSyntax:
                    return(RefValueExpression.Print(refValueExpressionSyntax));

                case RelationalPatternSyntax relationalPatternSyntax:
                    return(RelationalPattern.Print(relationalPatternSyntax));

                case ReturnStatementSyntax returnStatementSyntax:
                    return(ReturnStatement.Print(returnStatementSyntax));

                case SelectClauseSyntax selectClauseSyntax:
                    return(SelectClause.Print(selectClauseSyntax));

                case SimpleBaseTypeSyntax simpleBaseTypeSyntax:
                    return(SimpleBaseType.Print(simpleBaseTypeSyntax));

                case SimpleLambdaExpressionSyntax simpleLambdaExpressionSyntax:
                    return(SimpleLambdaExpression.Print(simpleLambdaExpressionSyntax));

                case SingleVariableDesignationSyntax singleVariableDesignationSyntax:
                    return(SingleVariableDesignation.Print(singleVariableDesignationSyntax));

                case SizeOfExpressionSyntax sizeOfExpressionSyntax:
                    return(SizeOfExpression.Print(sizeOfExpressionSyntax));

                case StackAllocArrayCreationExpressionSyntax stackAllocArrayCreationExpressionSyntax:
                    return(StackAllocArrayCreationExpression.Print(
                               stackAllocArrayCreationExpressionSyntax
                               ));

                case SwitchExpressionSyntax switchExpressionSyntax:
                    return(SwitchExpression.Print(switchExpressionSyntax));

                case SwitchSectionSyntax switchSectionSyntax:
                    return(SwitchSection.Print(switchSectionSyntax));

                case SwitchStatementSyntax switchStatementSyntax:
                    return(SwitchStatement.Print(switchStatementSyntax));

                case ThisExpressionSyntax thisExpressionSyntax:
                    return(ThisExpression.Print(thisExpressionSyntax));

                case ThrowExpressionSyntax throwExpressionSyntax:
                    return(ThrowExpression.Print(throwExpressionSyntax));

                case ThrowStatementSyntax throwStatementSyntax:
                    return(ThrowStatement.Print(throwStatementSyntax));

                case TryStatementSyntax tryStatementSyntax:
                    return(TryStatement.Print(tryStatementSyntax));

                case TupleElementSyntax tupleElementSyntax:
                    return(TupleElement.Print(tupleElementSyntax));

                case TupleExpressionSyntax tupleExpressionSyntax:
                    return(TupleExpression.Print(tupleExpressionSyntax));

                case TupleTypeSyntax tupleTypeSyntax:
                    return(TupleType.Print(tupleTypeSyntax));

                case TypeArgumentListSyntax typeArgumentListSyntax:
                    return(TypeArgumentList.Print(typeArgumentListSyntax));

                case TypeConstraintSyntax typeConstraintSyntax:
                    return(TypeConstraint.Print(typeConstraintSyntax));

                case TypeOfExpressionSyntax typeOfExpressionSyntax:
                    return(TypeOfExpression.Print(typeOfExpressionSyntax));

                case TypeParameterConstraintClauseSyntax typeParameterConstraintClauseSyntax:
                    return(TypeParameterConstraintClause.Print(
                               typeParameterConstraintClauseSyntax
                               ));

                case TypeParameterListSyntax typeParameterListSyntax:
                    return(TypeParameterList.Print(typeParameterListSyntax));

                case TypeParameterSyntax typeParameterSyntax:
                    return(TypeParameter.Print(typeParameterSyntax));

                case TypePatternSyntax typePatternSyntax:
                    return(TypePattern.Print(typePatternSyntax));

                case UnaryPatternSyntax unaryPatternSyntax:
                    return(UnaryPattern.Print(unaryPatternSyntax));

                case UnsafeStatementSyntax unsafeStatementSyntax:
                    return(UnsafeStatement.Print(unsafeStatementSyntax));

                case UsingDirectiveSyntax usingDirectiveSyntax:
                    return(UsingDirective.Print(usingDirectiveSyntax));

                case UsingStatementSyntax usingStatementSyntax:
                    return(UsingStatement.Print(usingStatementSyntax));

                case VariableDeclarationSyntax variableDeclarationSyntax:
                    return(VariableDeclaration.Print(variableDeclarationSyntax));

                case VariableDeclaratorSyntax variableDeclaratorSyntax:
                    return(VariableDeclarator.Print(variableDeclaratorSyntax));

                case VarPatternSyntax varPatternSyntax:
                    return(VarPattern.Print(varPatternSyntax));

                case WhenClauseSyntax whenClauseSyntax:
                    return(WhenClause.Print(whenClauseSyntax));

                case WhereClauseSyntax whereClauseSyntax:
                    return(WhereClause.Print(whereClauseSyntax));

                case WhileStatementSyntax whileStatementSyntax:
                    return(WhileStatement.Print(whileStatementSyntax));

                case WithExpressionSyntax withExpressionSyntax:
                    return(WithExpression.Print(withExpressionSyntax));

                case YieldStatementSyntax yieldStatementSyntax:
                    return(YieldStatement.Print(yieldStatementSyntax));

                default:
                    throw new Exception("Can't handle " + syntaxNode.GetType().Name);
                }
            }

            finally
            {
                depth--;
            }
        }
Exemplo n.º 13
0
 public bool ContainsPredefinedType(PredefinedType type) => _contextInfo.ContainsPredefinedType(type);
Exemplo n.º 14
0
 public AggregateType GetOptPredefType(PredefinedType pt)
 {
     return(GetOptPredefType(pt, true));
 }
Exemplo n.º 15
0
        private AggregateSymbol GetOptPredefAgg(PredefinedType pt, bool fEnsureState)
        {
            AggregateSymbol agg = GetTypeManager().GetOptPredefAgg(pt);

            return(agg);
        }
Exemplo n.º 16
0
 public AggregateSymbol GetOptPredefAgg(PredefinedType pt)
 {
     return(GetOptPredefAgg(pt, true));
 }
Exemplo n.º 17
0
 public bool ContainsPredefinedType(PredefinedType type) =>
 (_predefinedTypes & (int)type) == (int)type;
Exemplo n.º 18
0
 public bool isPredefType(PredefinedType pt)
 {
     if (IsAggregateType())
         return AsAggregateType().getAggregate().IsPredefined() && AsAggregateType().getAggregate().GetPredefType() == pt;
     return (IsVoidType() && pt == PredefinedType.PT_VOID);
 }
Exemplo n.º 19
0
 public AggregateSymbol GetReqPredefAgg(PredefinedType pt)
 {
     if (!PredefinedTypeFacts.IsRequired(pt)) throw Error.InternalCompilerError();
     if (_predefSyms[(int)pt] == null)
     {
         // Delay load this thing.
         _predefSyms[(int)pt] = DelayLoadPredefSym(pt);
     }
     return _predefSyms[(int)pt];
 }
Exemplo n.º 20
0
 public bool isPredefAgg(PredefinedType pt)
 {
     return(_isPredefined && (PredefinedType)_iPredef == pt);
 }
Exemplo n.º 21
0
 internal static string GetName(PredefinedType type)
 {
     return s_pdTypes[(int)type].name;
 }
Exemplo n.º 22
0
 public void SetPredefType(PredefinedType predef)
 {
     _iPredef = predef;
 }
Exemplo n.º 23
0
 internal static bool IsNumericType(PredefinedType type)
 {
     switch (type)
     {
         case PredefinedType.PT_BYTE:
         case PredefinedType.PT_SHORT:
         case PredefinedType.PT_INT:
         case PredefinedType.PT_LONG:
         case PredefinedType.PT_FLOAT:
         case PredefinedType.PT_DOUBLE:
         case PredefinedType.PT_DECIMAL:
         case PredefinedType.PT_SBYTE:
         case PredefinedType.PT_USHORT:
         case PredefinedType.PT_UINT:
         case PredefinedType.PT_ULONG:
             return true;
         default:
             return false;
     }
 }
Exemplo n.º 24
0
 internal PredefinedTypeInfo(PredefinedType type, Type associatedSystemType, string name)
     : this(type, associatedSystemType, name, FUNDTYPE.FT_REF)
 {
 }
Exemplo n.º 25
0
        internal static AggregateSymbol InitializePredefinedType(AggregateSymbol sym, PredefinedType pt)
        {
            sym.SetPredefined(true);
            sym.SetPredefType(pt);
            sym.SetSkipUDOps(pt <= PredefinedType.PT_ENUM && pt != PredefinedType.PT_INTPTR && pt != PredefinedType.PT_UINTPTR && pt != PredefinedType.PT_TYPE);

            return(sym);
        }
Exemplo n.º 26
0
 public static AggregateSymbol GetPredefinedAggregate(PredefinedType pt) =>
 s_predefSymbols[(int)pt] ?? (s_predefSymbols[(int)pt] = DelayLoadPredefSym(pt));
Exemplo n.º 27
0
 private AggregateSymbol GetOptPredefAgg(PredefinedType pt)
 {
     return GetSymbolLoader().GetOptPredefAgg(pt);
 }
Exemplo n.º 28
0
        ////////////////////////////////////////////////////////////////////////////////
        // Some of the predefined types have built-in names, like "int" or "string" or
        // "object". This return the nice name if one exists; otherwise null is
        // returned.

        private static string GetNiceName(PredefinedType pt) => PredefinedTypeFacts.GetNiceName(pt);
 private static bool CheckSingleType(PredefinedType predefinedType, IPsiModule psiModule, IType type, ITypeConversionRule conversionRule, IType typeInDeclaration)
 {
     if (!type.IsGenericOrNonIEnumerable())
     {
         if (!type.IsSubtypeOf(predefinedType.Array))
             return true;
         IDeclaredType scalarType = type.GetScalarType();
         return scalarType != null && scalarType.IsImplicitlyConvertibleTo(typeInDeclaration, conversionRule);
     }
     IDeclaredType ienumerableOf = CollectionTypeUtil.CreateIEnumerableOf(psiModule, typeInDeclaration);
     return ienumerableOf == null || type.IsImplicitlyConvertibleTo(ienumerableOf, conversionRule);
 }
Exemplo n.º 30
0
 internal static FUNDTYPE GetFundType(PredefinedType type) => s_types[(int)type].FundType;
Exemplo n.º 31
0
 internal static string GetName(PredefinedType type) => s_types[(int)type].Name;
Exemplo n.º 32
0
 internal static Type GetAssociatedSystemType(PredefinedType type) => s_types[(int)type].AssociatedSystemType;
Exemplo n.º 33
0
 public void SetPredefType(PredefinedType predef)
 {
     _iPredef = predef;
 }
Exemplo n.º 34
0
 internal static bool IsSimpleType(PredefinedType type) => type < PredefinedType.FirstNonSimpleType;
Exemplo n.º 35
0
        public void ReportMissingPredefTypeError(ErrorHandling errorContext, PredefinedType pt)
        {
            Debug.Assert(_pBSymmgr != null);
            Debug.Assert(_predefSyms != null);
            Debug.Assert((PredefinedType)0 <= pt && pt < PredefinedType.PT_COUNT && _predefSyms[(int)pt] == null);

            // We do not assert that !predefTypeInfo[pt].isRequired because if the user is defining
            // their own MSCorLib and is defining a required PredefType, they'll run into this error
            // and we need to allow it to go through.

            errorContext.Error(ErrorCode.ERR_PredefinedTypeNotFound, PredefinedTypeFacts.GetName(pt));
        }
Exemplo n.º 36
0
 internal static string GetNiceName(PredefinedType type) =>
 type switch
 {
Exemplo n.º 37
0
        public AggregateSymbol GetOptPredefAgg(PredefinedType pt)
        {
            if (_predefSyms[(int)pt] == null)
            {
                // Delay load this thing.
                _predefSyms[(int)pt] = DelayLoadPredefSym(pt);
            }

            Debug.Assert(_predefSyms != null);
            return _predefSyms[(int)pt];
        }
Exemplo n.º 38
0
 public bool ContainsPredefinedType(PredefinedType type)
 {
     return((predefinedTypes & (int)type) == (int)type);
 }
Exemplo n.º 39
0
 public static bool isRequired(PredefinedType pt)
 {
     return PredefinedTypeFacts.IsRequired(pt);
 }
Exemplo n.º 40
0
 public AggregateSymbol GetPredefAgg(PredefinedType pt) => _predefTypes.GetPredefinedAggregate(pt);
Exemplo n.º 41
0
 internal static bool IsRequired(PredefinedType type)
 {
     return s_pdTypes[(int)type].required;
 }
Exemplo n.º 42
0
 public AggregateSymbol GetPredefAgg(PredefinedType pt) => GetTypeManager().GetPredefAgg(pt);
Exemplo n.º 43
0
 internal static Type GetAssociatedSystemType(PredefinedType type)
 {
     return s_pdTypes[(int)type].AssociatedSystemType;
 }
Exemplo n.º 44
0
 public static AggregateSymbol GetPredefAgg(PredefinedType pt) => TypeManager.GetPredefAgg(pt);
Exemplo n.º 45
0
 internal static string GetNiceName(PredefinedType type)
 {
     switch (type)
     {
         case PredefinedType.PT_BYTE:
             return "byte";
         case PredefinedType.PT_SHORT:
             return "short";
         case PredefinedType.PT_INT:
             return "int";
         case PredefinedType.PT_LONG:
             return "long";
         case PredefinedType.PT_FLOAT:
             return "float";
         case PredefinedType.PT_DOUBLE:
             return "double";
         case PredefinedType.PT_DECIMAL:
             return "decimal";
         case PredefinedType.PT_CHAR:
             return "char";
         case PredefinedType.PT_BOOL:
             return "bool";
         case PredefinedType.PT_SBYTE:
             return "sbyte";
         case PredefinedType.PT_USHORT:
             return "ushort";
         case PredefinedType.PT_UINT:
             return "uint";
         case PredefinedType.PT_ULONG:
             return "ulong";
         case PredefinedType.PT_OBJECT:
             return "object";
         case PredefinedType.PT_STRING:
             return "string";
         default:
             return null;
     }
 }
 public bool TryGetPredefinedType(SyntaxToken token, out PredefinedType type)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 47
0
 internal PredefinedTypeInfo(PredefinedType type, Type associatedSystemType, string name, bool required, int arity, bool inMscorlib)
     : this(type, associatedSystemType, name, required, arity, AggKindEnum.Class, FUNDTYPE.FT_REF, inMscorlib)
 {
 }
Exemplo n.º 48
0
 public bool TryGetPredefinedType(SyntaxToken token, out PredefinedType type)
 {
     type = GetPredefinedType(token);
     return type != PredefinedType.None;
 }
Exemplo n.º 49
0
 public static AggregateType GetPredefindType(PredefinedType pt) => GetPredefAgg(pt).getThisType();
Exemplo n.º 50
0
 private AggregateSymbol GetPredefAgg(PredefinedType pt)
 {
     return(GetSymbolLoader().GetPredefAgg(pt));
 }
Exemplo n.º 51
0
 public bool IsPredefinedType(SyntaxToken token, PredefinedType type)
 {
     PredefinedType actualType;
     return TryGetPredefinedType(token, out actualType) && actualType == type;
 }
Exemplo n.º 52
0
            private AggCastResult bindExplicitConversionBetweenSimpleTypes(AggregateType aggTypeDest)
            {
                // 13.2.1
                //
                // Because the explicit conversions include all implicit and explicit numeric conversions,
                // it is always possible to convert from any numeric-type to any other numeric-type using
                // a cast expression (14.6.6).

                Debug.Assert(_typeSrc != null);
                Debug.Assert(aggTypeDest != null);

                if (!_typeSrc.IsSimpleType || !aggTypeDest.IsSimpleType)
                {
                    return(AggCastResult.Failure);
                }

                AggregateSymbol aggDest = aggTypeDest.OwningAggregate;

                Debug.Assert(_typeSrc.IsPredefined && aggDest.IsPredefined());

                PredefinedType ptSrc  = _typeSrc.PredefinedType;
                PredefinedType ptDest = aggDest.GetPredefType();

                Debug.Assert((int)ptSrc < NUM_SIMPLE_TYPES && (int)ptDest < NUM_SIMPLE_TYPES);

                ConvKind convertKind = GetConvKind(ptSrc, ptDest);

                // Identity and implicit conversions should already have been handled.
                Debug.Assert(convertKind != ConvKind.Implicit);
                Debug.Assert(convertKind != ConvKind.Identity);

                if (convertKind != ConvKind.Explicit)
                {
                    return(AggCastResult.Failure);
                }

                if (_exprSrc.GetConst() != null)
                {
                    // Fold the constant cast if possible.
                    ConstCastResult result = _binder.bindConstantCast(_exprSrc, _typeDest, _needsExprDest, out _exprDest, true);
                    if (result == ConstCastResult.Success)
                    {
                        return(AggCastResult.Success);  // else, don't fold and use a regular cast, below.
                    }
                    if (result == ConstCastResult.CheckFailure && 0 == (_flags & CONVERTTYPE.CHECKOVERFLOW))
                    {
                        return(AggCastResult.Abort);
                    }
                }

                bool bConversionOk = true;

                if (_needsExprDest)
                {
                    // Explicit conversions involving decimals are bound as user-defined conversions.
                    if (isUserDefinedConversion(ptSrc, ptDest))
                    {
                        // According the language, this is a standard conversion, but it is implemented
                        // through a user-defined conversion. Because it's a standard conversion, we don't
                        // test the CONVERTTYPE.NOUDC flag here.
                        bConversionOk = _binder.bindUserDefinedConversion(_exprSrc, _typeSrc, aggTypeDest, _needsExprDest, out _exprDest, false);
                    }
                    else
                    {
                        _binder.bindSimpleCast(_exprSrc, _typeDest, out _exprDest, (_flags & CONVERTTYPE.CHECKOVERFLOW) != 0 ? EXPRFLAG.EXF_CHECKOVERFLOW : 0);
                    }
                }
                return(bConversionOk ? AggCastResult.Success : AggCastResult.Failure);
            }
Exemplo n.º 53
0
        public int[] signature;       // Size 8. expand this if a new method has a signature which doesn't fit in the current space

        public PredefinedMethodInfo(PREDEFMETH method, MethodRequiredEnum required, PredefinedType type, PredefinedName name, MethodCallingConventionEnum callingConvention, ACCESS access, int cTypeVars, int[] signature)
        {
            this.method = method;
            this.type = type;
            this.name = name;
            this.callingConvention = callingConvention;
            this.access = access;
            this.cTypeVars = cTypeVars;
            this.signature = signature;
        }
Exemplo n.º 54
0
            private bool bindImplicitConversionBetweenSimpleTypes(AggregateType aggTypeSrc)
            {
                AggregateSymbol aggSrc = aggTypeSrc.getAggregate();

                Debug.Assert(aggSrc.getThisType().isSimpleType());
                Debug.Assert(_typeDest.isSimpleType());

                Debug.Assert(aggSrc.IsPredefined() && _typeDest.isPredefined());
                PredefinedType ptSrc  = aggSrc.GetPredefType();
                PredefinedType ptDest = _typeDest.getPredefType();
                ConvKind       convertKind;
                bool           fConstShrinkCast = false;

                Debug.Assert((int)ptSrc < NUM_SIMPLE_TYPES && (int)ptDest < NUM_SIMPLE_TYPES);

                // 13.1.7 Implicit constant expression conversions
                //
                // An implicit constant expression conversion permits the following conversions:
                // *   A constant-expression (14.16) of type int can be converted to type sbyte,  byte,  short,
                //     ushort,  uint, or ulong, provided the value of the constant-expression is within the range
                //     of the destination type.
                // *   A constant-expression of type long can be converted to type ulong, provided the value of
                //     the constant-expression is not negative.
                // Note: Don't use GetConst here since the conversion only applies to bona-fide compile time constants.
                if (_exprSrc != null && _exprSrc.isCONSTANT_OK() &&
                    ((ptSrc == PredefinedType.PT_INT && ptDest != PredefinedType.PT_BOOL && ptDest != PredefinedType.PT_CHAR) ||
                     (ptSrc == PredefinedType.PT_LONG && ptDest == PredefinedType.PT_ULONG)) &&
                    isConstantInRange(_exprSrc.asCONSTANT(), _typeDest))
                {
                    // Special case (CLR 6.1.6): if integral constant is in range, the conversion is a legal implicit conversion.
                    convertKind      = ConvKind.Implicit;
                    fConstShrinkCast = _needsExprDest && (GetConvKind(ptSrc, ptDest) != ConvKind.Implicit);
                }
                else if (ptSrc == ptDest)
                {
                    // Special case: precision limiting casts to float or double
                    Debug.Assert(ptSrc == PredefinedType.PT_FLOAT || ptSrc == PredefinedType.PT_DOUBLE);
                    Debug.Assert(0 != (_flags & CONVERTTYPE.ISEXPLICIT));
                    convertKind = ConvKind.Implicit;
                }
                else
                {
                    convertKind = GetConvKind(ptSrc, ptDest);
                    Debug.Assert(convertKind != ConvKind.Identity);
                    // identity conversion should have been handled at first.
                }

                if (convertKind != ConvKind.Implicit)
                {
                    return(false);
                }

                // An implicit conversion exists. Do the conversion.
                if (_exprSrc.GetConst() != null)
                {
                    // Fold the constant cast if possible.
                    ConstCastResult result = _binder.bindConstantCast(_exprSrc, _exprTypeDest, _needsExprDest, out _exprDest, false);
                    if (result == ConstCastResult.Success)
                    {
                        return(true);  // else, don't fold and use a regular cast, below.
                    }
                }

                if (isUserDefinedConversion(ptSrc, ptDest))
                {
                    if (!_needsExprDest)
                    {
                        return(true);
                    }
                    // According the language, this is a standard conversion, but it is implemented
                    // through a user-defined conversion. Because it's a standard conversion, we don't
                    // test the NOUDC flag here.
                    return(_binder.bindUserDefinedConversion(_exprSrc, aggTypeSrc, _typeDest, _needsExprDest, out _exprDest, true));
                }
                if (_needsExprDest)
                {
                    _binder.bindSimpleCast(_exprSrc, _exprTypeDest, out _exprDest);
                }
                return(true);
            }
Exemplo n.º 55
0
 private void ReportError(PredefinedType type, PredefinedName name)
 {
     GetErrorContext().Error(ErrorCode.ERR_MissingPredefinedMember, PredefinedTypes.GetFullName(type), GetPredefName(name));
 }
Exemplo n.º 56
0
 public bool TryGetPredefinedType(SyntaxToken token, out PredefinedType type)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 57
0
        protected virtual EXPRARRINIT GenerateMembersArray(AggregateType anonymousType, PredefinedType pt)
        {
            EXPR newArgs = null;
            EXPR newArgsTail = newArgs;
            int methodCount = 0;
            AggregateSymbol aggSym = anonymousType.getAggregate();

            for (Symbol member = aggSym.firstChild; member != null; member = member.nextChild)
            {
                if (member.IsMethodSymbol())
                {
                    MethodSymbol method = member.AsMethodSymbol();
                    if (method.MethKind() == MethodKindEnum.PropAccessor)
                    {
                        EXPRMETHODINFO methodInfo = GetExprFactory().CreateMethodInfo(method, anonymousType, method.Params);
                        GetExprFactory().AppendItemToList(methodInfo, ref newArgs, ref newArgsTail);
                        methodCount++;
                    }
                }
            }

            AggregateType paramsArrayElementType = GetSymbolLoader().GetOptPredefTypeErr(pt, true);
            ArrayType paramsArrayType = GetSymbolLoader().GetTypeManager().GetArray(paramsArrayElementType, 1);
            EXPRCONSTANT paramsArrayArg = GetExprFactory().CreateIntegerConstant(methodCount);
            EXPRARRINIT arrayInit = GetExprFactory().CreateArrayInit(EXPRFLAG.EXF_CANTBENULL, paramsArrayType, newArgs, paramsArrayArg, null);
            arrayInit.dimSize = methodCount;
            arrayInit.dimSizes = new int[] { arrayInit.dimSize }; // CLEANUP: Why isn't this done by the factory?
            return arrayInit;
        }
Exemplo n.º 58
0
        private BetterType WhichConversionIsBetter(CType argType, CType p1, CType p2)
        {
            Debug.Assert(argType != null);
            Debug.Assert(p1 != null);
            Debug.Assert(p2 != null);

            // 7.4.2.3 Better Conversion From Expression
            //
            // Given an implicit  conversion C1 that converts from an expression E to a type T1
            // and an implicit conversion C2 that converts from an expression E to a type T2, the
            // better conversion of the two conversions is determined as follows:
            //* if T1 and T2 are the same type, neither conversion is better.
            //* If E has a type S and the conversion from S to T1 is better than the conversion from
            //   S to T2 then C1 is the better conversion.
            //* If E has a type S and the conversion from S to T2 is better than the conversion from
            //   S to T1 then C2 is the better conversion.
            //* If E is a lambda expression or anonymous method for which an inferred return type X
            //   exists and T1 is a delegate type and T2 is a delegate type and T1 and T2 have identical
            //   parameter lists:
            //  * If T1 is a delegate of return type Y1 and T2 is a delegate of return type Y2 and the
            //     conversion from X to Y1 is better than the conversion from X to Y2, then C1 is the
            //     better return type.
            //  * If T1 is a delegate of return type Y1 and T2 is a delegate of return type Y2 and the
            //     conversion from X to Y2 is better than the conversion from X to Y1, then C2 is the
            //     better return type.

            if (p1 == p2)
            {
                return(BetterType.Same);
            }

            // 7.4.2.4 Better conversion from type
            //
            // Given a conversion C1 that converts from a type S to a type T1 and a conversion C2
            // that converts from a type S to a type T2, the better conversion of the two conversions
            // is determined as follows:
            //* If T1 and T2 are the same type, neither conversion is better
            //* If S is T1, C1 is the better conversion.
            //* If S is T2, C2 is the better conversion.
            //* If an implicit conversion from T1 to T2 exists and no implicit conversion from T2 to
            //   T1 exists, C1 is the better conversion.
            //* If an implicit conversion from T2 to T1 exists and no implicit conversion from T1 to
            //   T2 exists, C2 is the better conversion.
            //
            // [Otherwise, see table above for better integral type conversions.]

            if (argType == p1)
            {
                return(BetterType.Left);
            }

            if (argType == p2)
            {
                return(BetterType.Right);
            }

            bool a2b = canConvert(p1, p2);
            bool b2a = canConvert(p2, p1);

            if (a2b != b2a)
            {
                return(a2b ? BetterType.Left : BetterType.Right);
            }

            if (p1.isPredefined() && p2.isPredefined())
            {
                PredefinedType pt1 = p1.getPredefType();
                if (pt1 <= PredefinedType.PT_OBJECT)
                {
                    PredefinedType pt2 = p2.getPredefType();
                    if (pt2 <= PredefinedType.PT_OBJECT)
                    {
                        return((BetterType)s_betterConversionTable[(int)pt1][(int)pt2]);
                    }
                }
            }

            return(BetterType.Neither);
        }
 private bool HasCorrectType(PredefinedType predefinedType, IType type)
 {
     var typeConversionRule = myOwnerDeclaration.GetTypeConversionRule();
     if (type.IsString() || !type.IsSubtypeOf(predefinedType.IEnumerable))
         return false;
     var parameterDeclaration = myOwnerDeclaration as IRegularParameterDeclaration;
     if (parameterDeclaration != null)
         return CheckSingleType(predefinedType, myOwnerDeclaration.GetPsiModule(), type, typeConversionRule, parameterDeclaration.Type);
     var methodDeclaration = myOwnerDeclaration as IMethodDeclaration;
     if (methodDeclaration != null && methodDeclaration.ParameterDeclarations.Count == 1)
         return CheckSingleType(predefinedType, myOwnerDeclaration.GetPsiModule(), type, typeConversionRule, methodDeclaration.ParameterDeclarations[0].Type);
     return true;
 }
Exemplo n.º 60
0
 internal static Type GetAssociatedSystemType(PredefinedType type)
 {
     return(s_pdTypes[(int)type].AssociatedSystemType);
 }