//------------------------------------------------------------ // CLSDREC.IsValidAutoImplementedProperty // /// <summary></summary> /// <param name="propNode"></param> /// <returns></returns> //------------------------------------------------------------ internal bool IsValidAutoImplementedProperty(PROPERTYNODE propNode) { if (propNode == null || propNode.GetNode == null || propNode.GetNode.OpenCurlyIndex != propNode.GetNode.CloseCurlyIndex) { return(false); } if (propNode.SetNode == null) { // this message should be added to the resources. //Compiler.Controller.ReportError( // ERRORKIND.ERROR, // "Automatically implemented properties must define both get and set accessors."); NAMENODE nNode = propNode.NameNode as NAMENODE; Compiler.Error( propNode, CSCERRID.ERR_PropertyAccessorHasNoBody, new ErrArg(nNode != null ? nNode.Name : "")); return(false); } if (propNode.SetNode.OpenCurlyIndex == propNode.SetNode.CloseCurlyIndex) { propNode.GetNode.IsAutoImplemented = true; propNode.SetNode.IsAutoImplemented = true; return(true); } return(false); }
//------------------------------------------------------------ // FUNCBREC.EnsureNubHasValue // /// <summary> /// Make sure the HasValue property of System.Nullable<T> is appropriate (and return it). /// </summary> /// <param name="treeNode"></param> /// <returns></returns> //------------------------------------------------------------ private PROPSYM EnsureNubHasValue(BASENODE treeNode) { PROPSYM propSym = Compiler.MainSymbolManager.NullableHasValuePropertySym; if (propSym == null) { AGGSYM nubAggSym = Compiler.GetOptPredefAggErr(PREDEFTYPE.G_OPTIONAL, true); if (nubAggSym == null) { return(null); } string name = Compiler.NameManager.GetPredefinedName(PREDEFNAME.HASVALUE); SYM sym = Compiler.MainSymbolManager.LookupAggMember( name, nubAggSym, SYMBMASK.PROPSYM); propSym = sym as PROPSYM; if (propSym == null || propSym.IsStatic || propSym.Access != ACCESS.PUBLIC || propSym.ParameterTypes.Count > 0 || !propSym.ReturnTypeSym.IsPredefType(PREDEFTYPE.BOOL) || propSym.GetMethodSym == null) { Compiler.Error(treeNode, CSCERRID.ERR_MissingPredefinedMember, new ErrArg(nubAggSym), new ErrArg(name)); return(null); } Compiler.MainSymbolManager.NullableHasValuePropertySym = propSym; } return(propSym); }
//------------------------------------------------------------ // CLSDREC.SetForPartialMethod // /// <summary></summary> /// <param name="treeNode"></param> /// <param name="partialMethSym">the partial method</param> /// <param name="otherMethSym">the other method with the same signiture</param> /// <param name="errorID"></param> /// <returns></returns> //------------------------------------------------------------ internal bool CheckForDulicatePartialMethod( BASENODE treeNode, METHSYM partialMethSym, METHSYM otherMethSym) { if (partialMethSym == null || otherMethSym == null) { return(true); } if (!otherMethSym.IsPartialMethod) { Compiler.Error( treeNode, CSCERRID.ERR_MemberAlreadyExists, new ErrArg(partialMethSym), new ErrArg(partialMethSym.ClassSym)); return(false); } if (!partialMethSym.HasNoBody && !otherMethSym.HasNoBody) { Compiler.Error( treeNode, CSCERRID.ERR_MultiplePartialMethodImplementation); return(false); } return(true); }
//------------------------------------------------------------ // FUNCBREC.CreateAnonLocalName (2) // /// <summary></summary> /// <param name="name"></param> /// <returns></returns> //------------------------------------------------------------ internal string CreateAnonLocalName(string name) { if (this.localCount >= 0xffff) { Compiler.Error(treeNode, CSCERRID.ERR_TooManyLocals); } return(String.Format("<{0}>_local<{1}>", name, this.localCount++)); }
//------------------------------------------------------------ // FUNCBREC.BindImplicitlyTypedArrayInitCore // /// <summary></summary> /// <param name="treeUnOpNode"></param> /// <param name="elementTypeSym"></param> /// <param name="dimList"></param> /// <param name="dimIndex"></param> /// <param name="topArgList"></param> //------------------------------------------------------------ internal void BindImplicitlyTypedArrayInitCore( UNOPNODE treeUnOpNode, ref TYPESYM elementTypeSym, List <int> dimList, int dimIndex, ref EXPR topArgList) { int count = 0; EXPR lastArgList = null; BASENODE node = treeUnOpNode.Operand; while (node != null) { BASENODE itemNode; if (node.Kind == NODEKIND.LIST) { itemNode = node.AsLIST.Operand1.AsBASE; node = node.AsLIST.Operand2; } else { itemNode = node.AsBASE; node = null; } count++; EXPR expr = BindExpr(itemNode, BindFlagsEnum.RValueRequired); if (elementTypeSym == null || elementTypeSym.Kind == SYMKIND.IMPLICITTYPESYM) { elementTypeSym = expr.TypeSym; } else if (CanConvert(elementTypeSym, expr.TypeSym, ConvertTypeEnum.STANDARD)) { elementTypeSym = expr.TypeSym; } else if (!CanConvert(expr.TypeSym, elementTypeSym, ConvertTypeEnum.STANDARD)) { // do nothing here. } NewList(expr, ref topArgList, ref lastArgList); //exprList.Add(expr); } if (dimList[dimIndex] != -1) { if (dimList[dimIndex] != count) { Compiler.Error(treeUnOpNode, CSCERRID.ERR_InvalidArray); } } else { dimList[dimIndex] = count; } }
//------------------------------------------------------------ // FUNCBREC.BindNubNew // /// <summary> /// Create an expr for new T?(exprSrc) where T is exprSrc->type. /// </summary> /// <param name="treeNode"></param> /// <param name="srcExpr"></param> /// <returns></returns> //------------------------------------------------------------ private EXPR BindNubNew(BASENODE treeNode, EXPR srcExpr) { DebugUtil.Assert(srcExpr != null); // Create a NUBSYM instance whose base bype is represented by srcExpr.TypeSym. NUBSYM nubSym = Compiler.MainSymbolManager.GetNubType(srcExpr.TypeSym); // Get a TYPESYM instance representing Nullable<> for nubSym. AGGTYPESYM aggTypeSym = nubSym.GetAggTypeSym(); if (aggTypeSym == null) { return(NewError(treeNode, nubSym)); } Compiler.EnsureState(aggTypeSym, AggStateEnum.Prepared); METHSYM methSym = Compiler.MainSymbolManager.NullableCtorMethodSym; if (methSym == null) { string name = Compiler.NameManager.GetPredefinedName(PREDEFNAME.CTOR); for (SYM sym = Compiler.MainSymbolManager.LookupAggMember(name, aggTypeSym.GetAggregate(), SYMBMASK.ALL); ; sym = sym.NextSameNameSym) { if (sym == null) { Compiler.Error(treeNode, CSCERRID.ERR_MissingPredefinedMember, new ErrArg(aggTypeSym), new ErrArg(name)); return(NewError(treeNode, nubSym)); } if (sym.IsMETHSYM) { methSym = sym as METHSYM; if (methSym.ParameterTypes.Count == 1 && methSym.ParameterTypes[0].IsTYVARSYM && methSym.Access == ACCESS.PUBLIC) { break; } } } Compiler.MainSymbolManager.NullableCtorMethodSym = methSym; } EXPRCALL resExpr = NewExpr(treeNode, EXPRKIND.CALL, nubSym) as EXPRCALL; resExpr.MethodWithInst.Set(methSym, aggTypeSym, BSYMMGR.EmptyTypeArray); resExpr.ArgumentsExpr = srcExpr; resExpr.ObjectExpr = null; resExpr.Flags |= EXPRFLAG.NEWOBJCALL | EXPRFLAG.CANTBENULL; return(resExpr); }
//------------------------------------------------------------ // FUNCBREC.CreateAnonLocalName (1) // /// <summary></summary> /// <param name="kind"></param> /// <param name="name"></param> /// <returns></returns> //------------------------------------------------------------ internal string CreateAnonLocalName(string kind, string name) { if (String.IsNullOrEmpty(kind)) { return(CreateAnonLocalName(name)); } else { if (this.localCount >= 0xffff) { Compiler.Error(treeNode, CSCERRID.ERR_TooManyLocals); } return(String.Format("<{0}:{1}>_local<{2}>", kind, name, this.localCount++)); } }
//------------------------------------------------------------ // FUNCBREC.BindNubOpRes (1) // /// <summary> /// <para>Combine the condition and value.</para> /// <para>(In sscli, warOnNull has the default value false.)</para> /// </summary> /// <param name="treeNode"></param> /// <param name="nubSym"></param> /// <param name="dstTypeSym"></param> /// <param name="valueExpr"></param> /// <param name="nubInfo"></param> /// <param name="warnOnNull"></param> /// <returns></returns> //------------------------------------------------------------ private EXPR BindNubOpRes( BASENODE treeNode, NUBSYM nubSym, TYPESYM dstTypeSym, EXPR valueExpr, ref NubInfo nubInfo, bool warnOnNull) // = false { if (nubInfo.FAlwaysNull() && warnOnNull) { Compiler.Error(treeNode, CSCERRID.WRN_AlwaysNull, new ErrArg(nubSym)); } return(BindNubOpRes( treeNode, dstTypeSym, valueExpr, NewExprZero(treeNode, dstTypeSym.IsNUBSYM ? dstTypeSym : nubSym), ref nubInfo)); }
//------------------------------------------------------------ // FUNCBREC.EnsureNubGetValOrDef // /// <summary> /// Make sure the HasValue property of System.Nullable<T> is appropriate (and return it). /// </summary> /// <param name="treeNode"></param> /// <returns></returns> //------------------------------------------------------------ private METHSYM EnsureNubGetValOrDef(BASENODE treeNode) { METHSYM methSym = Compiler.MainSymbolManager.NullableGetValOrDefMethodSym; if (methSym == null) { AGGSYM nubAggSym = Compiler.GetOptPredefAggErr(PREDEFTYPE.G_OPTIONAL, true); if (nubAggSym == null) { return(null); } string name = Compiler.NameManager.GetPredefinedName(PREDEFNAME.GET_VALUE_OR_DEF); for (SYM sym = Compiler.MainSymbolManager.LookupAggMember(name, nubAggSym, SYMBMASK.ALL); ; sym = sym.NextSameNameSym) { if (sym == null) { Compiler.Error(treeNode, CSCERRID.ERR_MissingPredefinedMember, new ErrArg(nubAggSym), new ErrArg(name)); return(null); } if (sym.IsMETHSYM) { methSym = sym as METHSYM; if (methSym.ParameterTypes.Count == 0 && methSym.ParameterTypes.Count == 0 && methSym.ReturnTypeSym.IsTYVARSYM && !methSym.IsStatic && methSym.Access == ACCESS.PUBLIC) { break; } } } Compiler.MainSymbolManager.NullableGetValOrDefMethodSym = methSym; } return(methSym); }
//------------------------------------------------------------ // CLSDREC.DefineExtensionMethod // /// <summary></summary> /// <param name="methodNode"></param> /// <param name="methodSym"></param> //------------------------------------------------------------ internal void DefineExtensionMethod(METHODNODE methodNode, METHSYM methodSym) { DebugUtil.Assert( methodNode != null && methodNode.IsExtensionMethod && methodSym != null); //-------------------------------------------------------- // //-------------------------------------------------------- AGGSYM parentAggSym = methodSym.ParentAggSym; DebugUtil.Assert(parentAggSym != null); if (!methodSym.IsStatic) { Compiler.Error( methodNode, CSCERRID.ERR_NonStaticExtensionMethod); return; } if (!parentAggSym.IsStatic || (parentAggSym.AllTypeVariables != null && parentAggSym.AllTypeVariables.Count > 0)) { Compiler.Error( methodNode, CSCERRID.ERR_ExtensionMethodInImproperClass); return; } if (parentAggSym.IsNested) { Compiler.Error( methodNode, CSCERRID.ERR_ExtensionMethodInNestedClass, new ErrArg(parentAggSym.Name)); return; } DefineExtensionMethodCore(methodSym); }
//------------------------------------------------------------ // CLSDREC.CheckFlagsAndSigOfPartialMethod // /// <summary></summary> /// <param name="nodeFlags"></param> /// <param name="methodSym"></param> /// <returns></returns> //------------------------------------------------------------ internal void CheckFlagsAndSigOfPartialMethod( BASENODE treeNode, NODEFLAGS nodeFlags, METHSYM methodSym) { const NODEFLAGS forbidden = 0 | NODEFLAGS.MOD_ABSTRACT | NODEFLAGS.MOD_NEW | NODEFLAGS.MOD_OVERRIDE | NODEFLAGS.MOD_PRIVATE | NODEFLAGS.MOD_PROTECTED | NODEFLAGS.MOD_INTERNAL | NODEFLAGS.MOD_PUBLIC | NODEFLAGS.MOD_SEALED | NODEFLAGS.MOD_VIRTUAL | NODEFLAGS.MOD_EXTERN; if ((nodeFlags & forbidden) != 0) { Compiler.Error(treeNode, CSCERRID.ERR_BadModifierForPartialMethod); } TypeArray paramTypes = methodSym.ParameterTypes; if (paramTypes != null && paramTypes.Count > 0) { for (int i = 0; i < paramTypes.Count; ++i) { TYPESYM typeSym = paramTypes[i]; if (typeSym.Kind == SYMKIND.PARAMMODSYM && (typeSym as PARAMMODSYM).IsOut) { Compiler.Error( treeNode, CSCERRID.ERR_PartialMethodHasOutParameter); } } } }
//------------------------------------------------------------ // FUNCBREC.CreateNewLocVarSym // /// <summary>Increments the following values: /// FUNCBREC.localCount, /// FUNCBREC.unreferencedVarCount and /// FUNCBREC.uninitedVarCount. /// And sets LOCVARSYM.LocSlotInfo. /// </summary> /// <param name="name"></param> /// <param name="typeSym"></param> /// <param name="parentSym"></param> /// <returns></returns> //------------------------------------------------------------ internal LOCVARSYM CreateNewLocVarSym( string name, TYPESYM typeSym, PARENTSYM parentSym) { SYM sym = Compiler.LocalSymbolManager.LookupLocalSym( name, parentSym, SYMBMASK.LOCVARSYM); if (sym != null) { return(sym as LOCVARSYM); } LOCVARSYM locSym = Compiler.LocalSymbolManager.CreateLocalSym( SYMKIND.LOCVARSYM, name, parentSym) as LOCVARSYM; locSym.TypeSym = typeSym; StoreInCache(null, name, locSym, null, true); ++this.localCount; if (this.localCount > 0xffff) { Compiler.Error(treeNode, CSCERRID.ERR_TooManyLocals); } ++this.unreferencedVarCount; locSym.LocSlotInfo.SetJbitDefAssg(this.uninitedVarCount + 1); int cbit = FlowChecker.GetCbit(Compiler, locSym.TypeSym); this.uninitedVarCount += cbit; return(locSym); }
//------------------------------------------------------------ // FUNCBREC.HasIEnumerable (2) // /// <summary> /// Rewrite HasIEnumerable for collection initializer. /// Return the IEnumerable or IEnumerable<T> instance. /// </summary> /// <param name="collection"></param> /// <param name="tree"></param> /// <param name="badType"></param> /// <param name="badMember"></param> /// <returns></returns> //------------------------------------------------------------ private AGGTYPESYM HasIEnumerable( TYPESYM collectionTypeSym/*, * BASENODE treeNode, * TYPESYM badTypeSym, * PREDEFNAME badMemberName*/ ) { AGGTYPESYM ifaceCandidateAts = null; // First try the generic interfaces AGGSYM gEnumAggSym = Compiler.GetOptPredefAgg(PREDEFTYPE.G_IENUMERABLE, true); TypeArray allIfacesTypeArray = null; AGGTYPESYM baseAts = null; // If generics don't exist or the type isn't an AGGTYPESYM // then we can't check the interfaces (and base-class interfaces) // for IEnumerable<T> so immediately try the non-generic IEnumerable if (gEnumAggSym == null) { goto NO_GENERIC; } if (collectionTypeSym.IsAGGTYPESYM) { if (collectionTypeSym.GetAggregate() == gEnumAggSym || collectionTypeSym.IsPredefType(PREDEFTYPE.IENUMERABLE)) { DebugUtil.Assert(false, "IEnumerable/ator types are bad!"); goto LERROR; } AGGTYPESYM tempAts = collectionTypeSym as AGGTYPESYM; allIfacesTypeArray = tempAts.GetIfacesAll(); baseAts = tempAts.GetBaseClass(); } else if (collectionTypeSym.IsTYVARSYM) { // Note: // we'll search the interface list before the class constraint, // but it doesn't matter since we require a unique instantiation of IEnumerable<T>. // Note: // The pattern search will usually find the interface constraint // - but if the class constraint has a non-public or non-applicable // or non-method GetEnumerator, // the interfaces are hidden in which case we will find them here. TYVARSYM tempTvSym = collectionTypeSym as TYVARSYM; allIfacesTypeArray = tempTvSym.AllInterfaces; baseAts = tempTvSym.BaseClassSym; } else { goto NO_GENERIC; } DebugUtil.Assert(allIfacesTypeArray != null); // If the type implements exactly one instantiation of // IEnumerable<T> then it's the one. // // If it implements none then try the non-generic interface. // // If it implements more than one, then it's an error. // // Search the direct and indirect interfaces via allIfacesTypeArray, // going up the base chain... // Work up the base chain for (; ;) { // Now work across all the interfaces for (int i = 0; i < allIfacesTypeArray.Count; ++i) { AGGTYPESYM iface = allIfacesTypeArray[i] as AGGTYPESYM; if (iface.GetAggregate() == gEnumAggSym) { if (ifaceCandidateAts == null) { // First implementation ifaceCandidateAts = iface; } else if (iface != ifaceCandidateAts) { // If this really is a different instantiation report an error Compiler.Error( treeNode, CSCERRID.ERR_MultipleIEnumOfT, new ErrArgRef(collectionTypeSym), new ErrArg(gEnumAggSym.GetThisType())); return(null); } } } // Check the base class. if (baseAts == null) { break; } allIfacesTypeArray = baseAts.GetIfacesAll(); baseAts = baseAts.GetBaseClass(); } // Report the one and only generic interface if (ifaceCandidateAts != null) { DebugUtil.Assert( CanConvert(collectionTypeSym, ifaceCandidateAts, ConvertTypeEnum.NOUDC)); return(ifaceCandidateAts); } NO_GENERIC: if (collectionTypeSym.IsPredefType(PREDEFTYPE.IENUMERABLE)) { DebugUtil.VsFail("Why didn't IEnumerator match the pattern?"); goto LERROR; } // No errors, no generic interfaces, try the non-generic interface ifaceCandidateAts = GetRequiredPredefinedType(PREDEFTYPE.IENUMERABLE); if (CanConvert(collectionTypeSym, ifaceCandidateAts, ConvertTypeEnum.NOUDC)) { return(ifaceCandidateAts); } LERROR: return(null); }
//------------------------------------------------------------ // FUNCBREC.BindCollectionInitializer // /// <summary></summary> /// <param name="newNode"></param> /// <param name="typeSym"></param> /// <param name="locVarSym"></param> /// <param name="objectExpr"></param> /// <param name="builder"></param> /// <returns></returns> //------------------------------------------------------------ internal EXPR BindCollectionInitializer( NEWNODE newNode, BASENODE elementsNode, TYPESYM typeSym, LOCVARSYM locVarSym, EXPR leftExpr, EXPR rightExpr, StatementListBuilder builder) { DebugUtil.Assert(newNode != null && typeSym != null && builder != null); DebugUtil.Assert(locVarSym != null || leftExpr != null || rightExpr != null); string addMethName = Compiler.NameManager.GetPredefinedName(PREDEFNAME.ADD); //-------------------------------------------------------- // typeSym should implement IEnumerable. //-------------------------------------------------------- AGGTYPESYM enumerableSym = HasIEnumerable(typeSym); if (enumerableSym == null) { Compiler.Error( newNode.TypeNode, CSCERRID.ERR_CollectInitRequiresIEnumerable, new ErrArg(typeSym)); return(rightExpr); } TYPESYM paramTypeSym = null; TypeArray typeArgs = enumerableSym.TypeArguments; if (typeArgs != null && typeArgs.Count > 0) { DebugUtil.Assert(typeArgs.Count == 1); paramTypeSym = typeArgs[0]; } else { paramTypeSym = Compiler.GetReqPredefAgg(PREDEFTYPE.OBJECT, true).GetThisType(); if (typeArgs == null) { typeArgs = new TypeArray(); } typeArgs.Add(paramTypeSym); typeArgs = Compiler.MainSymbolManager.AllocParams(typeArgs); } BindFlagsEnum bindFlags = BindFlagsEnum.RValueRequired; string localFormat = "<{0}><{1}>__local"; //-------------------------------------------------------- // Bind the local variable. //-------------------------------------------------------- if (leftExpr == null) { if (locVarSym == null) { string locName = String.Format(localFormat, typeSym.Name, (this.localCount)++); locVarSym = Compiler.LocalSymbolManager.CreateLocalSym( SYMKIND.LOCVARSYM, locName, this.currentScopeSym) as LOCVARSYM; locVarSym.TypeSym = typeSym; locVarSym.LocSlotInfo.HasInit = true; locVarSym.DeclTreeNode = newNode; StoreInCache(newNode, locName, locVarSym, null, true); } leftExpr = BindToLocal( newNode, locVarSym, bindFlags | BindFlagsEnum.MemberSet); } //-------------------------------------------------------- // If objectExpr is not null, assign it to the local variable. //-------------------------------------------------------- if (rightExpr != null) { EXPR assignLocExpr = BindAssignment( newNode, leftExpr, rightExpr, false); builder.Add(SetNodeStmt(newNode, MakeStmt(newNode, assignLocExpr, 0))); } //-------------------------------------------------------- // Get "Add" method. //-------------------------------------------------------- MemberLookup mem = new MemberLookup(); if (!mem.Lookup( Compiler, typeSym, leftExpr, this.parentDeclSym, addMethName, 0, MemLookFlagsEnum.UserCallable)) { Compiler.Error( newNode.TypeNode, CSCERRID.ERR_NoSuchMember, new ErrArg(typeSym), new ErrArg("Add")); return(NewError(newNode, null)); } if (mem.FirstSym == null || !mem.FirstSym.IsMETHSYM) { return(NewError(newNode, null)); } TypeArray typeGroup = mem.GetAllTypes(); EXPRMEMGRP grpExpr = NewExpr( newNode, EXPRKIND.MEMGRP, Compiler.MainSymbolManager.MethodGroupTypeSym) as EXPRMEMGRP; grpExpr.Name = addMethName; grpExpr.SymKind = SYMKIND.METHSYM; grpExpr.TypeArguments = BSYMMGR.EmptyTypeArray; grpExpr.ParentTypeSym = typeSym; grpExpr.MethPropSym = null; grpExpr.ObjectExpr = leftExpr; grpExpr.ContainingTypeArray = typeGroup; grpExpr.Flags |= EXPRFLAG.USERCALLABLE; //-------------------------------------------------------- // Add each value. //-------------------------------------------------------- DebugUtil.Assert(newNode.InitialNode != null); #if false BASENODE node = null; switch (newNode.InitialNode.Kind) { case NODEKIND.DECLSTMT: node = (newNode.InitialNode as DECLSTMTNODE).VariablesNode; break; case NODEKIND.UNOP: node = (newNode.InitialNode as UNOPNODE).Operand; break; default: DebugUtil.Assert(false); break; } #endif BASENODE node = elementsNode; while (node != null) { BASENODE elementNode; if (node.Kind == NODEKIND.LIST) { elementNode = node.AsLIST.Operand1; node = node.AsLIST.Operand2; } else { elementNode = node; node = null; } //---------------------------------------------------- // Bind the elements //---------------------------------------------------- EXPR elementExpr = BindExpr( elementNode, BindFlagsEnum.RValueRequired); //---------------------------------------------------- // Add the elements //---------------------------------------------------- EXPR addExpr = BindGrpToArgs(newNode, bindFlags, grpExpr, elementExpr); if (addExpr != null) { builder.Add(SetNodeStmt(newNode, MakeStmt(newNode, addExpr, 0))); } } return(leftExpr); }
//------------------------------------------------------------ // FUNCBREC.SetFncBrecExtFields // /// <summary></summary> /// <returns></returns> //------------------------------------------------------------ private bool SetFncBrecExtFields() { if (systemNsSym == null) { systemNsSym = Compiler.LookupInBagAid( "System", Compiler.MainSymbolManager.RootNamespaceSym, 0, 0, SYMBMASK.NSSYM) as NSSYM; } if (systemNsSym == null) { Compiler.Error(CSCERRID.ERR_SingleTypeNameNotFound, new ErrArg("System")); return(false); } if (reflectionNsSym == null) { reflectionNsSym = Compiler.LookupInBagAid( "Reflection", systemNsSym, 0, 0, SYMBMASK.NSSYM) as NSSYM; } if (reflectionNsSym == null) { Compiler.Error(CSCERRID.ERR_SingleTypeNameNotFound, new ErrArg("Reflection")); return(false); } if (systemTypeAggTypeSym == null) { systemTypeAggSym = Compiler.LookupInBagAid( "Type", systemNsSym, 0, 0, SYMBMASK.AGGSYM) as AGGSYM; systemTypeAggTypeSym = systemTypeAggSym.GetThisType(); } if (systemTypeAggTypeSym == null) { Compiler.Error(CSCERRID.ERR_SingleTypeNameNotFound, new ErrArg("Type")); return(false); } if (systemTypeArraySym == null) { systemTypeArraySym = Compiler.MainSymbolManager.GetArray( systemTypeAggTypeSym, 1, systemTypeAggTypeSym.Type.MakeArrayType()); } if (systemTypeArraySym == null) { Compiler.Error(CSCERRID.ERR_SingleTypeNameNotFound, new ErrArg("Type[]")); return(false); } return(true); }
//------------------------------------------------------------ // FUNCBREC.BindImplicitlyTypedArrayInitConvert // /// <summary></summary> /// <param name="elementTypeSym"></param> /// <param name="dimList"></param> /// <param name="dimIndex"></param> /// <param name="argListExpr"></param> /// <param name="nonConstCount"></param> /// <param name="constCount"></param> /// <param name="hasSideEffects"></param> //------------------------------------------------------------ internal void BindImplicitlyTypedArrayInitConvert( TYPESYM elementTypeSym, List <int> dimList, int dimIndex, ref EXPR argListExpr, ref int nonConstCount, ref int constCount, ref bool hasSideEffects) { int count = 0; EXPR nodeExpr = argListExpr; EXPR topArgList = null, lastArgList = null; while (nodeExpr != null) { EXPR argExpr; if (nodeExpr.Kind == EXPRKIND.LIST) { EXPRBINOP listExpr = nodeExpr as EXPRBINOP; argExpr = listExpr.Operand1; nodeExpr = listExpr.Operand2; } else { argExpr = nodeExpr; nodeExpr = null; } count++; EXPR expr = null; #if false expr = MustConvert( argExpr, elementTypeSym, 0); #endif if (!BindImplicitConversion( argExpr.TreeNode, argExpr, argExpr.TypeSym, elementTypeSym, ref expr, 0)) { Compiler.Error(argExpr.TreeNode, CSCERRID.ERR_NoBestTypeForArray); expr = NewError(treeNode, elementTypeSym); } EXPR constExpr = expr.GetConst(); if (constExpr != null) { if (!constExpr.IsZero(true)) { ++constCount; } if (expr.HasSideEffects(Compiler)) { hasSideEffects = true; } } else { nonConstCount++; } NewList(expr, ref topArgList, ref lastArgList); //exprList.Add(expr); } argListExpr = topArgList; }