protected override string ConstructDataModel(UserDefinedType type) { // Build the list of fields as properties of the generated class StringBuilder fieldList = new StringBuilder(); StringBuilder propertyList = new StringBuilder(); foreach (UDTField field in type.Fields) { string fieldName = GetParameterName(field.Identifier); fieldList.AppendLine($" let mutable m_{fieldName} : {GetDataTypeName(field.Type)} = {fieldName}"); propertyList.AppendLine($" member public this.{field.Identifier} with get() = m_{fieldName} and set(value) = m_{fieldName} <- value"); } string constructorParams = string.Join(", ", type.Fields .Select(param => $"{GetParameterName(param.Identifier)} : {GetDataTypeName(param.Type)}")); string defaultConstructorParams = string.Join(", ", type.Fields .Select(param => $"{GetDefaultDataValue(param.Type)}")); // Generate the contents of the class file return(GetTextFromResource("ECAClientUtilities.Template.FSharp.UDTDataTemplate.txt") .Replace("{ProjectName}", ProjectName) .Replace("{Category}", type.Category) .Replace("{Identifier}", type.Identifier) .Replace("{Fields}", $"{fieldList}{Environment.NewLine}{propertyList}") .Replace("{ConstructorParams}", constructorParams) .Replace("{DefaultConstructorParams}", defaultConstructorParams)); }
// Writes the file that contains the user's algorithm to the given path. private void WriteAlgorithmTo(string path, UserDefinedType inputType, UserDefinedType outputType) { // Determine the path to the file containing the user's algorithm string algorithmPath = Path.Combine(path, $"Algorithm.{m_fileSuffix}"); // Do not overwrite the user's algorithm if (File.Exists(algorithmPath)) { return; } // Generate usings for the namespaces of the classes the user needs for their inputs and outputs string usings = string.Join(Environment.NewLine, new[] { inputType, outputType } .Select(ConstructUsing) .Distinct() .OrderBy(str => str)); // Write the contents of the user's algorithm class to the class file File.WriteAllText(algorithmPath, GetTextFromResource($"ECAClientUtilities.Template.{m_subFolder}.AlgorithmTemplate.txt") .Replace("{Usings}", usings) .Replace("{OutputUsing}", ConstructUsing(outputType)) .Replace("{ProjectName}", m_projectName) .Replace("{ConnectionString}", $"\"{m_settings.SubscriberConnectionString.Replace("\"", "\"\"")}\"") .Replace("{ConnectionStringSingleQuote}", $"\'{m_settings.SubscriberConnectionString.Replace("'", "''''")}\'") .Replace("{InputDataType}", inputType.Identifier) .Replace("{InputMetaType}", GetMetaIdentifier(inputType.Identifier)) .Replace("{OutputDataType}", outputType.Identifier)); }
public List <Script> GenereateUserDefinedTypeChangedScripts(DbDifference difference, string targetDbOwner) { List <Script> scripts = new List <Script>(); DbDifferenceType diffType = difference.DifferenceType; UserDefinedType source = difference.Source as UserDefinedType; UserDefinedType target = difference.Target as UserDefinedType; if (diffType == DbDifferenceType.Added) { var cloneObj = this.CloneDbObject(source, targetDbOwner); scripts.Add(this.targetScriptGenerator.AddUserDefinedType(cloneObj)); } else if (diffType == DbDifferenceType.Deleted) { scripts.Add(this.targetScriptGenerator.DropUserDefinedType(source)); } else if (diffType == DbDifferenceType.Modified) { var cloneObj = this.CloneDbObject(source, target.Owner); scripts.Add(this.targetScriptGenerator.DropUserDefinedType(target)); scripts.Add(this.targetScriptGenerator.AddUserDefinedType(cloneObj)); } return(scripts); }
static UserDefinedTypeCache() { TypeAttribute typeAttribute = typeof(T).GetCustomAttribute(typeof(TypeAttribute)) as TypeAttribute; if (typeAttribute == null) { throw new TypeLoadException($"Unable to cache type {typeof(T).Name} as it does not have a 'Type' attribute"); } Dictionary <string, PropertyInfo> properties = new Dictionary <string, PropertyInfo>(); Dictionary <string, string> aliases = new Dictionary <string, string>(); foreach (PropertyInfo property in typeof(T).GetProperties()) { if (Attribute.IsDefined(property, typeof(IgnoreAttribute))) { continue; } ColumnAttribute column = property.GetCustomAttribute(typeof(ColumnAttribute)) as ColumnAttribute; string columnName = column?.Name ?? property.Name; properties.Add(columnName, property); aliases.Add(property.Name, columnName); } CachedType = new UserDefinedType() { Columns = properties, KeyspaceName = typeAttribute.KeyspaceName, TypeName = typeAttribute.TypeName ?? typeof(T).Name, Aliases = aliases }; }
/// <summary> /// http://dlang.org/operatoroverloading.html#Dispatch /// Check for the existence of an opDispatch overload. /// Important: Because static opDispatches are allowed as well, do check whether we can access non-static overloads from non-instance expressions or such /// </summary> public static IEnumerable<AbstractType> TryResolveFurtherIdViaOpDispatch (ResolutionContext ctxt, int nextIdentifierHash, UserDefinedType b, ISyntaxRegion typeBase = null) { // The usual SO prevention if (nextIdentifierHash == opDispatchId || b == null) yield break; AbstractType[] overloads; var opt = ctxt.CurrentContext.ContextDependentOptions; // Look for opDispatch-Members inside b's Definition using (ctxt.Push(b)) { ctxt.CurrentContext.ContextDependentOptions = opt; // Mainly required for not resolving opDispatch's return type, as this will be performed later on in higher levels overloads = TypeDeclarationResolver.ResolveFurtherTypeIdentifier(opDispatchId, b, ctxt, typeBase, false); } if (overloads == null || overloads.Length < 0) yield break; var av = new ArrayValue (Evaluation.GetStringType(ctxt), Strings.TryGet(nextIdentifierHash)); foreach (DSymbol o in overloads) { var dn = o.Definition; if (dn.TemplateParameters != null && dn.TemplateParameters.Length > 0 && dn.TemplateParameters[0] is TemplateValueParameter) { //TODO: Test parameter types for being a string value o.SetDeducedTypes(new[]{ new TemplateParameterSymbol(dn.TemplateParameters[0], av) }); yield return o; } } }
public void AddTypeWellFormed(List <RtlExp> specs, RtlExp exp, bool isGhost, Type t, List <UserDefinedType> recs) { UserDefinedType ut = t as UserDefinedType; if (minVerify && !isGhost && t is IntType) { specs.Add(new RtlApply("word", new RtlExp[] { exp })); return; } if (t is NatType) { specs.Add(new RtlBinary(">=", exp, new RtlInt(0))); } if (ut != null && ut.AsDatatype != null && recs.TrueForAll(r => ut.Name != r.Name) ) { recs.Add(ut); foreach (var ctor in ut.AsDatatype.Ctors) { List <RtlExp> cspecs = new List <RtlExp>(); foreach (var f in ctor.Formals) { AddTypeWellFormed(cspecs, new RtlLiteral(f.Name + "#" + ctor.Name + "(" + exp + ")"), isGhost, f.Type, recs); } foreach (var spec in cspecs) { specs.Add(new RtlLiteral("((" + exp + ") is " + ctor.Name + " ==> (" + spec + "))")); } } recs.RemoveAt(recs.Count - 1); } }
public override void Visit(TypeRhs e) { UserDefinedType t = null; if (e.Type is UserDefinedType type) { t = type; } if (t == null) { return; } var nav = new SymbolNavigator(); var declaration = nav.GetSymbolAtPosition(RootNode, t.ResolvedClass.tok); CreateSymbol( name: t.Name, kind: Kind.Class, type: e.Type, positionAsToken: t.tok, bodyStartPosAsToken: e.Tok, //"new" bodyEndPosAsToken: t.tok, //ClassName isDeclaration: false, declarationSymbol: declaration, addUsageAtDeclaration: true, canHaveChildren: false, canBeUsed: false ); }
public override ArmadaLValue ApplyExprDotName(IToken i_tok, ResolutionContext context, string fieldName, Type ty) { if (!(type is UserDefinedType)) { context.Fail(i_tok, $"Attempt to take a field ({fieldName}) of non-struct, non-datatype type {type}"); return(null); } UserDefinedType ut = (UserDefinedType)type; if (context.symbols.DoesStructExist(ut.Name)) { Type fieldType = context.symbols.GetStructFieldType(ut.Name, fieldName); if (fieldType == null) { context.Fail(i_tok, $"Attempt to take non-existent field ({fieldName}) in struct type {ut.Name}"); return(null); } if (!AH.TypesMatch(fieldType, ty)) { context.Fail(i_tok, $"Field {fieldName} of type {fieldType} used as type {ty}"); return(null); } } return(new UnaddressableFieldArmadaLValue(i_tok, ty, this, crashAvoidance, fieldName, false)); }
/// <summary> /// Carga los tipos definidos por el usuario /// </summary> /// <returns>Tables </returns> internal UserDefinedTypes LoadUserDefinedTypes() { DataTable wDttTypes = null; UserDefinedType wUserDefinedType; UserDefinedTypes wUserDefinedTypes = new UserDefinedTypes(); Tables wTables = new Tables(); try { wDttTypes = GetUserDefinedTypesFromDataBase(); wDttTypes.TableName = "Types"; foreach (DataRow oDtr in wDttTypes.Rows) { wUserDefinedType = new UserDefinedType(); wUserDefinedType.Name = oDtr["Name"].ToString(); wUserDefinedType.Nullable = Convert.ToBoolean(oDtr["Nullable"]); wUserDefinedType.Length = Convert.ToInt32(oDtr["Length"]); wUserDefinedType.NumericPrecision = Convert.ToInt32(oDtr["NumericPrecision"]); wUserDefinedType.Schema = oDtr["Schema"].ToString(); wUserDefinedType.SystemType = oDtr["SystemType"].ToString(); wUserDefinedTypes.Add(wUserDefinedType); } wDttTypes.Dispose(); wDttTypes = null; OnAddElementEvent(); return(wUserDefinedTypes); } catch (Exception ex) { throw ex; } }
private ISymbol?GetTypeSymbol(UserDefinedType userDefinedType) { return(userDefinedType.ResolvedClass switch { NonNullTypeDecl nonNullTypeDeclaration => GetSymbolByDeclaration(nonNullTypeDeclaration.Class), IndDatatypeDecl dataTypeDeclaration => GetSymbolByDeclaration(dataTypeDeclaration), _ => null });
public static bool CheckTypeTac(UserDefinedType type, string tacName, ProofState state, out string errMsg) { if (state.Tactics.ContainsKey(tacName)) { var tac = state.Tactics[tacName]; if (type.TypeArgs.Count != tac.Ins.Count) { errMsg = "The number of args doesn't match the tactic typ " + type; return(false); } for (var i = 0; i < tac.Ins.Count; i++) { var name = tac.Ins[i].Type.ToString(); if (tac.Ins[i].Type.ToString() != type.TypeArgs[i].ToString()) { errMsg = tacName + " doesn't match the tactic typ " + type; return(false); } } errMsg = ""; return(true); } else { errMsg = tacName + " is not a tactic."; return(false); } }
public bool TryGetTypeSymbol(Type type, [NotNullWhen(true)] out ISymbol?typeSymbol) { typeSymbol = type switch { UserDefinedType userDefinedType => GetTypeSymbol(userDefinedType), _ => null }; return(typeSymbol != null); }
public static List <INode> EnumChildren(UserDefinedType ds, ResolutionContext ctxt, MemberFilter VisibleMembers) { var en = new ItemEnumeration(ctxt); en.DeepScanClass(ds, VisibleMembers); return(en.Nodes); }
public static List<INode> EnumChildren(UserDefinedType ds,ResolutionContext ctxt, MemberFilter VisibleMembers) { var en = new ItemEnumeration(ctxt); en.DeepScanClass(ds, new ItemCheckParameters(VisibleMembers)); return en.Nodes; }
// REVIEW: is this receiving the correct typeArgs? public TypeApply Compile_Constructor(Type t, string constructor, Dictionary <TypeParameter, Type> typeArgs) { UserDefinedType ut = (UserDefinedType)t; Dictionary <string, TypeParameter> substArgs = new Dictionary <string, TypeParameter>(); ut.AsDatatype.TypeArgs.ForEach(tt => substArgs.Add(tt.Name, tt)); typeArgs = typeArgs.ToDictionary(p => substArgs[p.Key.Name], p => p.Value); return(new TypeApply(this, constructor, ut.AsDatatype.TypeArgs, typeArgs)); }
public void AddUDT(UserDefinedType udt) { UDTWriter udtWriter = new UDTWriter(); udtWriter.Types.Add(udt); lock (s_udtLock) udtWriter.WriteFiles(s_udtDirectory); }
public string TypeString(Type t) { t = ToType(t); MapType mt = t as MapType; UserDefinedType ut = t as UserDefinedType; SeqType seq = t as SeqType; if (t is BoolType) { return("bool"); } else if (t is IntType) { return("int"); } else if (t is RealType) { return("real"); } else if (mt != null) { return("[" + TypeString(mt.Domain) + "]" + TypeString(mt.Range)); } else if (ut != null && ut.AsDatatype != null) { return(Compile_Datatype(ut).AppName()); } else if (ut != null && ut.Name == "array") { if (!(ToType(ut.TypeArgs[0]) is IntType) || ToType(ut.TypeArgs[0]) is NatType) { throw new Exception("not implemented: arrays of non-int types: " + ToType(ut.TypeArgs[0])); } return("ArrayOfInt"); } else if (ut != null && ut.Name == "INTERNAL_AbsMem") { return("[int][int]int"); } else if (ut != null && ut.Name == "INTERNAL_ArrayElems") { return("[int]int"); } else if (ut != null && !ut.IsTypeParameter) { return(ut.Name); } else if (seq != null) { return(Compile_SeqType(seq).AppName()); } else { throw new Exception("not implemented: " + t + ": " + t.GetType()); } }
public override string GetStepParameters() { var parameters = new List <string>(); parameters.Add(Elements != null ? Elements.ToStepValue() : "$"); parameters.Add(UnitType.ToStepValue()); parameters.Add(UserDefinedType != null ? UserDefinedType.ToStepValue() : "$"); return(string.Join(", ", parameters.ToArray())); }
public static string GetBitWidth(UserDefinedType uty) { Match match = Regex.Match(uty.Name, @"^u?int(\d+)$"); if (!match.Success) { throw new Exception("Failed to find the bit-width of: " + uty); } return("" + match.Groups[1]); }
/// <summary> /// Creates a tuple value that stores the given LLVM value representing a Q# value of user defined type. /// </summary> /// <param name="value">The typed tuple representing a value of user defined type</param> /// <param name="udt">The Q# type of the value</param> internal TupleValue FromCustomType(Value value, UserDefinedType udt) { if (!this.sharedState.TryGetCustomType(udt.GetFullName(), out var udtDecl)) { throw new ArgumentException("type declaration not found"); } var elementTypes = udtDecl.Type.Resolution is ResolvedTypeKind.TupleType ts ? ts.Item : ImmutableArray.Create(udtDecl.Type); return(new TupleValue(udt, value, elementTypes, this.sharedState)); }
protected override string ConstructDataModel(UserDefinedType type) { string fieldList = string.Join(", ", type.Fields.Select(field => $"'{field.Identifier}', {GetDefaultDataValue(field.Type)}")); // Generate the contents of the class file return(GetTextFromResource("ECAClientUtilities.Template.Matlab.UDTTemplate.txt") .Replace("{ProjectName}", ProjectName) .Replace("{Category}", type.Category) .Replace("{Identifier}", type.Identifier) .Replace("{Fields}", fieldList.Trim())); }
public List <TypeMapping> GetMappings(UserDefinedType udt, bool isOutput) { if (isOutput) { return(GetOutputMappings(udt)); } else { return(GetInputMappings(udt)); } }
protected override string ConstructMetaModel(UserDefinedType type) { string fieldList = string.Join(Environment.NewLine, type.Fields .Select(field => $" public {GetMetaTypeName(field.Type)} {field.Identifier} {{ get; set; }}")); // Generate the contents of the class file return(GetTextFromResource("ECAClientUtilities.Template.CSharp.UDTMetaTemplate.txt") .Replace("{ProjectName}", ProjectName) .Replace("{Category}", type.Category) .Replace("{Identifier}", GetMetaIdentifier(type.Identifier)) .Replace("{Fields}", fieldList.Trim())); }
protected override string ConstructDataModel(UserDefinedType type) { string fieldList = string.Join(Environment.NewLine, type.Fields .Select(field => $" Public Property {field.Identifier} As {GetDataTypeName(field.Type)}")); // Generate the contents of the class file return(GetTextFromResource("ECAClientUtilities.Template.VisualBasic.UDTDataTemplate.txt") .Replace("{ProjectName}", ProjectName) .Replace("{Category}", type.Category) .Replace("{Identifier}", type.Identifier) .Replace("{Fields}", fieldList.Trim())); }
private void SetColumnCellsReadonly(DataGridViewRow row) { DataGridViewCell lengthCell = row.Cells[this.colLength.Name]; DataGridViewCell primaryCell = row.Cells[this.colPrimary.Name]; DataGridViewCell identityCell = row.Cells[this.colIdentity.Name]; string dataType = DataGridViewHelper.GetCellStringValue(row, this.colDataType.Name); if (!string.IsNullOrEmpty(dataType)) { UserDefinedType userDefindedType = this.GetUserDefinedType(dataType); if (userDefindedType != null) { dataType = userDefindedType.Type; } DataTypeSpecification dataTypeSpec = this.dataTypeSpecifications.FirstOrDefault(item => item.Name == dataType); if (dataTypeSpec != null) { bool isLengthReadOnly = userDefindedType != null || string.IsNullOrEmpty(dataTypeSpec.Args); bool isPrimaryReadOnly = dataTypeSpec.IndexForbidden; bool isIdentityReadOnly = !dataTypeSpec.AllowIdentity; lengthCell.ReadOnly = isLengthReadOnly; primaryCell.ReadOnly = isPrimaryReadOnly; identityCell.ReadOnly = isIdentityReadOnly; if (isLengthReadOnly) { lengthCell.Value = null; } if (isPrimaryReadOnly) { primaryCell.Value = false; } if (isIdentityReadOnly) { identityCell.Value = false; } } } else { lengthCell.ReadOnly = true; primaryCell.ReadOnly = true; identityCell.ReadOnly = true; } }
public void UserTypeToString() { var c = new UserDefinedType { Key1 = 123, Key2 = "Hello", Key3 = new int[] { 1, 2, 3 } }; Assert.AreEqual("{ Key1: 123, Key2: Hello, Key3: {1, 2, 3} }", c.ToStringEx()); var c2 = new UserDefinedTypeWithToString { Key = 123 }; Assert.AreEqual("Hello world!", c2.ToStringEx()); }
private void Write(TextWriter writer, UserDefinedType type) { writer.WriteLine($"category {type.Category}"); writer.WriteLine($"{type.Identifier} {{"); foreach (UDTField field in type.Fields) { writer.WriteLine($" {field.Type.Category} {field.Type.Identifier} {field.Identifier}"); } writer.WriteLine("}"); writer.WriteLine(); }
public UserDefinedType FindType(string name) { foreach (Dictionary <string, UserDefinedType> frame in userDefinedTypes) { UserDefinedType type = null; bool findResult = frame.TryGetValue(name, out type); if (findResult) { return(type); } } throw new Exception("Type " + name + " not find."); }
public void UpdateUDT(UserDefinedType udt, string oldCat, string oldIdent) { UDTCompiler udtCompiler = CreateUDTCompiler(); MappingCompiler mappingCompiler = new MappingCompiler(udtCompiler); mappingCompiler.Scan(s_udmDirectory); foreach (UserDefinedType dt in udtCompiler.DefinedTypes.OfType <UserDefinedType>()) { if (dt.Category == oldCat && dt.Identifier == oldIdent) { dt.Fields.Clear(); foreach (UDTField dataType in udt.Fields) { dt.Fields.Add(dataType); } dt.Category = udt.Category; dt.Identifier = udt.Identifier; } } string categoryPath = Path.Combine(s_udtDirectory, oldCat); string typePath = Path.Combine(categoryPath, oldIdent + ".ecaidl"); lock (s_udtLock) { File.Delete(typePath); if (!Directory.EnumerateFileSystemEntries(categoryPath).Any()) { Directory.Delete(categoryPath); } } UDTWriter udtWriter = new UDTWriter(); udtWriter.Types.AddRange(udtCompiler.DefinedTypes.OfType <UserDefinedType>()); lock (s_udtLock) udtWriter.WriteFiles(s_udtDirectory); MappingWriter mappingWriter = new MappingWriter(); mappingWriter.Mappings.AddRange(mappingCompiler.DefinedMappings); lock (s_udmLock) mappingWriter.WriteFiles(s_udmDirectory); }
/// <summary> /// //LDTEST012 Implicit Conversions /// </summary> private static void Test012() { UserDefinedType udt = new UserDefinedType(5); //LD with the call below we are looking to receive a "double" and we are passing a "UserDefinedType" // the framework will automatically call the method with that signature on the object in context "UserDefinedType" double num = udt; //VICEVERSA, This call invokes the implicit "UserDefinedType" operator, I want "UserDefinedType" starting from the int "5" UserDefinedType udt2 = 5; Console.WriteLine("num = {0} dig2 = {1}", num, udt2.aNumber); Console.ReadLine(); }
public List <TableColumnDesingerInfo> GetColumns() { List <TableColumnDesingerInfo> columnDesingerInfos = new List <TableColumnDesingerInfo>(); int order = 1; foreach (DataGridViewRow row in this.dgvColumns.Rows) { TableColumnDesingerInfo col = new TableColumnDesingerInfo() { Order = order }; string colName = row.Cells[this.colColumnName.Name].Value?.ToString(); if (!string.IsNullOrEmpty(colName)) { TableColumnDesingerInfo tag = row.Tag as TableColumnDesingerInfo; string dataType = DataGridViewHelper.GetCellStringValue(row, this.colDataType.Name); col.OldName = tag?.OldName; col.Name = colName; col.DataType = dataType; col.Length = DataGridViewHelper.GetCellStringValue(row, this.colLength.Name); col.IsNullable = DataGridViewHelper.GetCellBoolValue(row, this.colNullable.Name); col.IsPrimary = DataGridViewHelper.GetCellBoolValue(row, this.colPrimary.Name); col.IsIdentity = DataGridViewHelper.GetCellBoolValue(row, this.colIdentity.Name); col.DefaultValue = DataGridViewHelper.GetCellStringValue(row, this.colDefaultValue.Name); col.Comment = DataGridViewHelper.GetCellStringValue(row, this.colComment.Name); col.ExtraPropertyInfo = tag?.ExtraPropertyInfo; UserDefinedType userDefinedType = this.GetUserDefinedType(dataType); if (userDefinedType != null) { col.IsUserDefined = true; col.TypeOwner = userDefinedType.Owner; } row.Tag = col; columnDesingerInfos.Add(col); order++; } } return(columnDesingerInfos); }
public override Script AddUserDefinedType(UserDefinedType userDefinedType) { string userTypeName = userDefinedType.Name; TableColumn column = new TableColumn() { DataType = userDefinedType.Type, MaxLength = userDefinedType.MaxLength, Precision = userDefinedType.Precision, Scale = userDefinedType.Scale }; string dataLength = this.dbInterpreter.GetColumnDataLength(column); string script = $@"CREATE TYPE {this.GetQuotedString(userDefinedType.Owner)}.{this.GetQuotedString(userTypeName)} FROM {this.GetQuotedString(userDefinedType.Type)}{(dataLength == "" ? "" : "(" + dataLength + ")")} {(userDefinedType.IsRequired ? "NOT NULL" : "NULL")};"; return(new CreateDbObjectScript <UserDefinedType>(script)); }
/// <summary> /// http://dlang.org/operatoroverloading.html#Dispatch /// Check for the existence of an opDispatch overload. /// Important: Because static opDispatches are allowed as well, do check whether we can access non-static overloads from non-instance expressions or such /// </summary> public static IEnumerable<AbstractType> TryResolveFurtherIdViaOpDispatch(ResolutionContext ctxt, int nextIdentifierHash, UserDefinedType b) { // The usual SO prevention if (nextIdentifierHash == opDispatchId || b == null) yield break; var pop = ctxt.ScopedBlock != b.Definition; if (pop) { // Mainly required for not resolving opDispatch's return type, as this will be performed later on in higher levels var opt = ctxt.CurrentContext.ContextDependentOptions; ctxt.PushNewScope (b.Definition as IBlockNode); ctxt.CurrentContext.IntroduceTemplateParameterTypes (b); ctxt.CurrentContext.ContextDependentOptions = opt; } // Look for opDispatch-Members inside b's Definition var overloads = TypeDeclarationResolver.ResolveFurtherTypeIdentifier (opDispatchId, new[]{b}, ctxt); if(pop) ctxt.Pop (); if (overloads == null || overloads.Length < 0) yield break; var av = new ArrayValue (Evaluation.GetStringType(ctxt), Strings.TryGet(nextIdentifierHash)); foreach (DSymbol o in overloads) { var dn = o.Definition; if (dn.TemplateParameters != null && dn.TemplateParameters.Length > 0 && dn.TemplateParameters[0] is TemplateValueParameter) { //TODO: Test parameter types for being a string value o.DeducedTypes = new System.Collections.ObjectModel.ReadOnlyCollection<TemplateParameterSymbol> ( new[]{ new TemplateParameterSymbol(dn.TemplateParameters[0], av) } ); yield return o; } } }
/// <summary> /// Carga los tipos definidos por el usuario /// </summary> /// <returns>Tables </returns> internal UserDefinedTypes LoadUserDefinedTypes() { DataTable wDttTypes = null; UserDefinedType wUserDefinedType; UserDefinedTypes wUserDefinedTypes = new UserDefinedTypes(); Tables wTables = new Tables(); try { wDttTypes = GetUserDefinedTypesFromDataBase(); wDttTypes.TableName = "Types"; foreach (DataRow oDtr in wDttTypes.Rows) { wUserDefinedType = new UserDefinedType(); wUserDefinedType.Name = oDtr["Name"].ToString(); wUserDefinedType.Nullable = Convert.ToBoolean(oDtr["Nullable"]); wUserDefinedType.Length = Convert.ToInt32(oDtr["Length"]); wUserDefinedType.NumericPrecision = Convert.ToInt32(oDtr["NumericPrecision"]); wUserDefinedType.Schema = oDtr["Schema"].ToString(); wUserDefinedType.SystemType = oDtr["SystemType"].ToString(); wUserDefinedTypes.Add(wUserDefinedType); } wDttTypes.Dispose(); wDttTypes = null; OnAddElementEvent(); return wUserDefinedTypes; } catch (Exception ex) { throw ex; } }
void MatchCasePrelude(UserDefinedType sourceType, DatatypeCtor ctor, List<BoundVar/*!*/>/*!*/ arguments, int caseIndex, int caseCount) { Contract.Requires(sourceType != null); Contract.Requires(ctor != null); Contract.Requires(cce.NonNullElements(arguments)); // bugbug: implement WriteEAbort("MatchCasePrelude"); }
// Do what "new TypeName();" would have done in .NET. See WriteClassStruct() // for the code that emits the DTypeFlat. This function creates an instance // of that type. void WriteClassAllocation(UserDefinedType udt) { var c = (udt.ResolvedClass) as ClassDecl; using (WriteArray()) { j.WriteValue(KremlinAst.EBufCreateL); // of expr list using (WriteArray()) { using (WriteArray()) { j.WriteValue(KremlinAst.EFlat); using (WriteArray()) { // (lident list of (ident * expr) WriteLident(udt); using (WriteArray()) { foreach (var member in c.InheritedMembers) { Contract.Assert(!member.IsGhost && !member.IsStatic); // only non-ghost instance members should ever be added to .InheritedMembers j.WriteComment("Inherited member"); using (WriteArray()) { if (member is Field) { var f = (Field)member; using (WriteArray()) { // (ident * expr) j.WriteValue(f.Name); WriteDefaultValue(f.Type); } } } } foreach (MemberDecl member in c.Members) { if (member is Field) { var f = (Field)member; if (f.IsGhost) { // emit nothing } else if (c is TraitDecl) { WriteToken(member.tok); j.WriteComment("BUGBUG TraitDecl not supported: " + f.CompileName); // bugbug: implement } else { using (WriteArray()) { // (ident * expr) j.WriteValue(f.Name); WriteDefaultValue(f.Type); } } } } } } } } } }
public Tuple<Method,TypeApply> GetSeqBuildMethod(Type t, SeqTree tree, List<bool> elemDimensions) { if (elemDimensions.Count == 0) { return GetSeqMethod(t, "seq_Empty"); } if (elemDimensions.Count == 2 && elemDimensions[0] && elemDimensions[1]) { return GetSeqMethod(t, "seq_Append"); } string op = "seq_" + SeqTree.TreeName(tree); DatatypeDecl seqDecl = FindDatatype("Seq"); var tok = new Bpl.Token(0, 0); tok.filename = @"!\Seq.dfy"; TypeApply tApp = Compile_SeqType((SeqType)t); Type dataType = new UserDefinedType(tok, "Seq", seqDecl, new List<Type> { ((SeqType)t).Arg }); Type elemType = ((SeqType)t).Arg; Func<string,Type,Expression> idExpr = (x, typ) => { var e = new IdentifierExpr(tok, x); e.Type = typ; e.Var = new LocalVariable(tok, tok, x, typ, false); return e; }; Func<string,List<Expression>,FunctionCallExpr> seqCall = (x, args) => { var seqOp = GetSeqOperation(t, x); FunctionCallExpr callExpr = new FunctionCallExpr( tok, "Seq_Empty", new ThisExpr(tok), tok, args); callExpr.Function = seqOp.Item1; callExpr.TypeArgumentSubstitutions = seqOp.Item2.typeArgs; return callExpr; }; Expression empty = seqCall("Seq_Empty", new List<Expression> {}); int varCount = 0; Func<SeqTree,Expression> resultRec = null; resultRec = (subtree) => { if (subtree == null) { return idExpr("s" + (varCount++), dataType); } if (subtree.buildCount >= 0) { Expression build = empty; for (int i = 0; i < subtree.buildCount; i++) { build = seqCall("Seq_Build", new List<Expression> { build, idExpr("a" + (varCount++), elemType) }); } return build; } else { return seqCall("Seq_Append", new List<Expression> { resultRec(subtree.left), resultRec(subtree.right) }); } }; Expression result = resultRec(tree); Expression post = seqCall("Seq_Equal", new List<Expression> { idExpr("s", dataType), result }); List<Statement> stmts = new List<Statement>(); for (int i = elemDimensions.Count; i > 0;) { bool isFirst = (i == elemDimensions.Count); i--; if (elemDimensions[i]) { if (isFirst) { stmts.Add(new AssignStmt(tok, tok, idExpr("s", dataType), new ExprRhs(idExpr("s" + i, dataType)))); } else { // s := seq_Append(s9, s); var selectExpr = new MemberSelectExpr(tok, new ThisExpr(tok), "seq_Append"); selectExpr.Member = FindMethod(selectExpr.MemberName); // Manually resolve here selectExpr.TypeApplication = new List<Type>() { elemType }; // Manually resolve here selectExpr.Type = new InferredTypeProxy(); // Manually resolve here CallStmt callStmt = new CallStmt(tok, tok, new List<Expression> {idExpr("s", dataType)}, selectExpr, new List<Expression> { idExpr("s" + i, dataType), idExpr("s", dataType) }); stmts.Add(callStmt); } } else { if (isFirst) { DatatypeValue nil = new DatatypeValue(tok, "Seq", "Nil", new List<Expression>() {}); nil.Type = dataType; nil.InferredTypeArgs = new List<Type> { elemType }; nil.Ctor = seqDecl.Ctors[0]; Util.Assert(nil.Ctor.Name == "Seq_Nil"); stmts.Add(new AssignStmt(tok, tok, idExpr("s", dataType), new ExprRhs(nil))); } // lemma_Seq_Cons(ai, s); var selectExpr = new MemberSelectExpr(tok, new ThisExpr(tok), "lemma_Seq_Cons"); selectExpr.Member = FindMethod(selectExpr.MemberName); // Manually resolve here selectExpr.TypeApplication = new List<Type>() { elemType }; // Manually resolve here selectExpr.Type = new InferredTypeProxy(); // Manually resolve here CallStmt callStmt = new CallStmt(tok, tok, new List<Expression> {}, selectExpr, new List<Expression> { idExpr("a" + i, elemType), idExpr("s", dataType) }); callStmt.IsGhost = true; stmts.Add(callStmt); DatatypeValue cons = new DatatypeValue(tok, "Seq", "Cons", new List<Expression>() { idExpr("a" + i, elemType), idExpr("s", dataType) }); cons.Type = dataType; cons.InferredTypeArgs = new List<Type> { elemType }; cons.Ctor = seqDecl.Ctors[1]; Util.Assert(cons.Ctor.Name == "Seq_Cons"); stmts.Add(new AssignStmt(tok, tok, idExpr("s", dataType), new ExprRhs(cons))); } } BlockStmt body = new BlockStmt(tok, tok, stmts); List<Formal> ins = new List<Formal>(); for (int i = 0; i < elemDimensions.Count; i++) { bool isSeq = elemDimensions[i]; ins.Add(new Formal(tok, (isSeq ? "s" : "a") + i, isSeq ? dataType : elemType, true, false)); } List<Formal> outs = new List<Formal> { new Formal(tok, "s", dataType, false, false) }; List<MaybeFreeExpression> reqs = new List<MaybeFreeExpression>(); List<MaybeFreeExpression> enss = new List<MaybeFreeExpression> { new MaybeFreeExpression(post) }; Specification<FrameExpression> mods = new Specification<FrameExpression>(new List<FrameExpression>(), null); Specification<Expression> decs = new Specification<Expression>(new List<Expression>(), null); Attributes attrs = new Attributes("dafnycc_conservative_seq_triggers", new List<Expression>(), null); Method m = new Method(tok, op, true, false, tApp.typeParams, ins, outs, reqs, mods, enss, decs, body, attrs, tok); m.EnclosingClass = GetSeqMethod(t, "seq_Append").Item1.EnclosingClass; return Tuple.Create(m, Compile_Method(m, tApp.typeArgs)); }
public override void AddDatatypeLemmas(UserDefinedType t, TypeApply apply) { switch (t.Name) { case "Seq": { List<TypeApply> lemmaApps = new List<TypeApply>(); Dictionary<string,string> loopLemmas = new Dictionary<string,string>(); foreach (string lemmaName in seqLemmas) { Method lemma = FindMethod(lemmaName); var a = Compile_Method(lemma, apply.typeArgs); lemmaApps.Add(a); if (Attributes.Contains(lemma.Attributes, "loop_lemma")) { loopLemmas.Add(a.AppName(), ""); } } Type elementType = (t.TypeArgs.Count == 1) ? t.TypeArgs[0] : null; lemmaApps.ForEach(a => lemmas.Add(new LemmaCall("Seq", elementType, "call " + ProcName(true, SimpleName(a.AppName())) + "();", loopLemmas.ContainsKey(a.AppName())))); break; } } }
public TypeApply Compile_Datatype(UserDefinedType t) { Dictionary<TypeParameter,Type> subst = new Dictionary<TypeParameter,Type>(); for (int i = 0; i < t.TypeArgs.Count; i++) { subst.Add(t.AsDatatype.TypeArgs[i], t.TypeArgs[i]); } TypeApply apply = new TypeApply(this, t.Name, t.AsDatatype.TypeArgs, subst); if ( !compileDatatypes.ContainsKey(apply) && !Attributes.Contains(t.AsDatatype.Attributes, "imported")) { compileDatatypes.Add(apply, t); compileDatatypeList.Add(apply); AddDatatypeLemmas(t, apply); } return apply; }
public virtual void AddDatatypeLemmas(UserDefinedType t, TypeApply apply) { }
public bool CheckIsRefinement(ModuleSignature derived, ModuleSignature original) { // Check refinement by construction. var derivedPointer = derived; while (derivedPointer != null) { if (derivedPointer == original) return true; derivedPointer = derivedPointer.Refines; } // Check structural refinement. Note this involves several checks. // First, we need to know if the two modules are signature compatible; // this is determined immediately as it is necessary for determining // whether resolution will succeed. This involves checking classes, datatypes, // type declarations, and nested modules. // Second, we need to determine whether the specifications will be compatible // (i.e. substitutable), by translating to Boogie. var errorCount = reporter.Count(ErrorLevel.Error); foreach (var kv in original.TopLevels) { var d = kv.Value; TopLevelDecl nw; if (derived.TopLevels.TryGetValue(kv.Key, out nw)) { if (d is ModuleDecl) { if (!(nw is ModuleDecl)) { reporter.Error(MessageSource.RefinementTransformer, nw, "a module ({0}) must refine another module", nw.Name); } else { CheckIsRefinement(((ModuleDecl)nw).Signature, ((ModuleDecl)d).Signature); } } else if (d is OpaqueTypeDecl) { if (nw is ModuleDecl) { reporter.Error(MessageSource.RefinementTransformer, nw, "a module ({0}) must refine another module", nw.Name); } else { bool dDemandsEqualitySupport = ((OpaqueTypeDecl)d).MustSupportEquality; if (nw is OpaqueTypeDecl) { if (dDemandsEqualitySupport != ((OpaqueTypeDecl)nw).MustSupportEquality) { reporter.Error(MessageSource.RefinementTransformer, nw, "type declaration '{0}' is not allowed to change the requirement of supporting equality", nw.Name); } } else if (dDemandsEqualitySupport) { if (nw is ClassDecl) { // fine, as long as "nw" does not take any type parameters if (nw.TypeArgs.Count != 0) { reporter.Error(MessageSource.RefinementTransformer, nw, "opaque type '{0}' is not allowed to be replaced by a class that takes type parameters", nw.Name); } } else if (nw is CoDatatypeDecl) { reporter.Error(MessageSource.RefinementTransformer, nw, "a type declaration that requires equality support cannot be replaced by a codatatype"); } else { Contract.Assert(nw is IndDatatypeDecl); if (nw.TypeArgs.Count != 0) { reporter.Error(MessageSource.RefinementTransformer, nw, "opaque type '{0}' is not allowed to be replaced by a datatype that takes type parameters", nw.Name); } else { var udt = new UserDefinedType(nw.tok, nw.Name, nw, new List<Type>()); if (!(udt.SupportsEquality)) { reporter.Error(MessageSource.RefinementTransformer, nw.tok, "datatype '{0}' is used to refine an opaque type with equality support, but '{0}' does not support equality", nw.Name); } } } } } } else if (d is DatatypeDecl) { if (nw is DatatypeDecl) { if (d is IndDatatypeDecl && !(nw is IndDatatypeDecl)) { reporter.Error(MessageSource.RefinementTransformer, nw, "a datatype ({0}) must be replaced by a datatype, not a codatatype", d.Name); } else if (d is CoDatatypeDecl && !(nw is CoDatatypeDecl)) { reporter.Error(MessageSource.RefinementTransformer, nw, "a codatatype ({0}) must be replaced by a codatatype, not a datatype", d.Name); } // check constructors, formals, etc. CheckDatatypesAreRefinements((DatatypeDecl)d, (DatatypeDecl)nw); } else { reporter.Error(MessageSource.RefinementTransformer, nw, "a {0} ({1}) must be refined by a {0}", d is IndDatatypeDecl ? "datatype" : "codatatype", d.Name); } } else if (d is ClassDecl) { if (!(nw is ClassDecl)) { reporter.Error(MessageSource.RefinementTransformer, nw, "a class declaration ({0}) must be refined by another class declaration", nw.Name); } else { CheckClassesAreRefinements((ClassDecl)nw, (ClassDecl)d); } } else { Contract.Assert(false); throw new cce.UnreachableException(); // unexpected toplevel } } else { reporter.Error(MessageSource.RefinementTransformer, d, "declaration {0} must have a matching declaration in the refining module", d.Name); } } return errorCount == reporter.Count(ErrorLevel.Error); }
void MatchCasePrelude(string source, UserDefinedType sourceType, DatatypeCtor ctor, List<BoundVar/*!*/>/*!*/ arguments, int caseIndex, int caseCount, int indent, TextWriter wr) { Contract.Requires(source != null); Contract.Requires(sourceType != null); Contract.Requires(ctor != null); Contract.Requires(cce.NonNullElements(arguments)); Contract.Requires(0 <= indent); // if (source.is_Ctor0) { // FormalType f0 = ((Dt_Ctor0)source._D).a0; // ... Indent(indent, wr); wr.Write("{0}if (", caseIndex == 0 ? "" : "} else "); if (caseIndex == caseCount - 1) { wr.Write("true"); } else { wr.Write("{0}.is_{1}", source, ctor.CompileName); } wr.WriteLine(") {"); int k = 0; // number of processed non-ghost arguments for (int m = 0; m < ctor.Formals.Count; m++) { Formal arg = ctor.Formals[m]; if (!arg.IsGhost) { BoundVar bv = arguments[m]; // FormalType f0 = ((Dt_Ctor0)source._D).a0; Indent(indent + IndentAmount, wr); wr.WriteLine("{0} @{1} = (({2}){3}._D).@{4};", TypeName(bv.Type, wr), bv.CompileName, DtCtorName(ctor, sourceType.TypeArgs, wr), source, FormalName(arg, k)); k++; } } }
void TypeAndToken(out IToken tok, out Type ty, bool inExpressionContext) { Contract.Ensures(Contract.ValueAtReturn(out tok)!=null); Contract.Ensures(Contract.ValueAtReturn(out ty) != null); tok = Token.NoToken; ty = new BoolType(); /*keep compiler happy*/ List<Type> gt; List<Type> tupleArgTypes = null; switch (la.kind) { case 7: { Get(); tok = t; break; } case 8: { Get(); tok = t; ty = new CharType(); break; } case 9: { Get(); tok = t; ty = new IntType(); break; } case 10: { Get(); tok = t; ty = new UserDefinedType(tok, tok.val, null); break; } case 11: { Get(); tok = t; ty = new RealType(); break; } case 6: { Get(); tok = t; int w = StringToInt(tok.val.Substring(2), 0, "bitvectors that wide"); ty = new BitvectorType(w); break; } case 12: { Get(); tok = t; ty = new ObjectType(); break; } case 14: { Get(); tok = t; OptGenericInstantiation(out gt, inExpressionContext); if (gt != null && gt.Count > 1) { SemErr("set type expects only one type argument"); } ty = new SetType(true, gt != null ?gt[0] : null); break; } case 15: { Get(); tok = t; OptGenericInstantiation(out gt, inExpressionContext); if (gt != null && gt.Count > 1) { SemErr("set type expects only one type argument"); } ty = new SetType(false, gt != null ? gt[0] : null); break; } case 16: { Get(); tok = t; OptGenericInstantiation(out gt, inExpressionContext); if (gt != null && gt.Count > 1) { SemErr("multiset type expects only one type argument"); } ty = new MultiSetType(gt != null ? gt[0] : null); break; } case 17: { Get(); tok = t; OptGenericInstantiation(out gt, inExpressionContext); if (gt != null && gt.Count > 1) { SemErr("seq type expects only one type argument"); } ty = new SeqType(gt != null ? gt[0] : null); break; } case 13: { Get(); tok = t; ty = new UserDefinedType(tok, tok.val, null); break; } case 18: { Get(); tok = t; OptGenericInstantiation(out gt, inExpressionContext); if (gt == null) { ty = new MapType(true, null, null); } else if (gt.Count != 2) { SemErr("map type expects two type arguments"); ty = new MapType(true, gt[0], gt.Count == 1 ? new InferredTypeProxy() : gt[1]); } else { ty = new MapType(true, gt[0], gt[1]); } break; } case 19: { Get(); tok = t; OptGenericInstantiation(out gt, inExpressionContext); if (gt == null) { ty = new MapType(false, null, null); } else if (gt.Count != 2) { SemErr("imap type expects two type arguments"); ty = new MapType(false, gt[0], gt.Count == 1 ? new InferredTypeProxy() : gt[1]); } else { ty = new MapType(false, gt[0], gt[1]); } break; } case 5: { Get(); tok = t; OptGenericInstantiation(out gt, inExpressionContext); int dims = StringToInt(tok.val.Substring(5), 1, "arrays of that many dimensions"); ty = theBuiltIns.ArrayType(tok, dims, gt, true); break; } case 54: { Get(); tok = t; tupleArgTypes = new List<Type>(); if (StartOf(6)) { Type(out ty); tupleArgTypes.Add(ty); while (la.kind == 23) { Get(); Type(out ty); tupleArgTypes.Add(ty); } } Expect(55); if (tupleArgTypes.Count == 1) { // just return the type 'ty' } else { var dims = tupleArgTypes.Count; var tmp = theBuiltIns.TupleType(tok, dims, true); // make sure the tuple type exists ty = new UserDefinedType(tok, BuiltIns.TupleTypeName(dims), dims == 0 ? null : tupleArgTypes); } break; } case 1: { Expression e; NameSegmentForTypeName(out e, inExpressionContext); tok = t; while (la.kind == 28) { Get(); Expect(1); tok = t; List<Type> typeArgs; OptGenericInstantiation(out typeArgs, inExpressionContext); e = new ExprDotName(tok, e, tok.val, typeArgs); } ty = new UserDefinedType(e.tok, e); break; } default: SynErr(182); break; } if (IsArrow()) { Expect(32); tok = t; Type t2; Type(out t2); if (tupleArgTypes != null) { gt = tupleArgTypes; } else { gt = new List<Type>{ ty }; } ty = new ArrowType(tok, gt, t2); theBuiltIns.CreateArrowTypeDecl(gt.Count); } }
void TypeAndToken(out IToken tok, out Type ty) { Contract.Ensures(Contract.ValueAtReturn(out tok)!=null); Contract.Ensures(Contract.ValueAtReturn(out ty) != null); tok = Token.NoToken; ty = new BoolType(); /*keep compiler happy*/ List<Type> gt; List<Type> tupleArgTypes = null; switch (la.kind) { case 6: { Get(); tok = t; break; } case 7: { Get(); tok = t; ty = new CharType(); break; } case 9: { Get(); tok = t; ty = new NatType(); break; } case 8: { Get(); tok = t; ty = new IntType(); break; } case 10: { Get(); tok = t; ty = new RealType(); break; } case 11: { Get(); tok = t; ty = new ObjectType(); break; } case 13: { Get(); tok = t; gt = new List<Type>(); if (la.kind == 52) { GenericInstantiation(gt); } if (gt.Count > 1) { SemErr("set type expects only one type argument"); } ty = new SetType(true, gt.Count == 1 ? gt[0] : null); break; } case 14: { Get(); tok = t; gt = new List<Type>(); if (la.kind == 52) { GenericInstantiation(gt); } if (gt.Count > 1) { SemErr("set type expects only one type argument"); } ty = new SetType(false, gt.Count == 1 ? gt[0] : null); break; } case 15: { Get(); tok = t; gt = new List<Type>(); if (la.kind == 52) { GenericInstantiation(gt); } if (gt.Count > 1) { SemErr("multiset type expects only one type argument"); } ty = new MultiSetType(gt.Count == 1 ? gt[0] : null); break; } case 16: { Get(); tok = t; gt = new List<Type>(); if (la.kind == 52) { GenericInstantiation(gt); } if (gt.Count > 1) { SemErr("seq type expects only one type argument"); } ty = new SeqType(gt.Count == 1 ? gt[0] : null); break; } case 12: { Get(); tok = t; ty = new UserDefinedType(tok, tok.val, null); break; } case 17: { Get(); tok = t; gt = new List<Type>(); if (la.kind == 52) { GenericInstantiation(gt); } if (gt.Count == 0) { ty = new MapType(true, null, null); } else if (gt.Count != 2) { SemErr("map type expects two type arguments"); ty = new MapType(true, gt[0], gt.Count == 1 ? new InferredTypeProxy() : gt[1]); } else { ty = new MapType(true, gt[0], gt[1]); } break; } case 18: { Get(); tok = t; gt = new List<Type>(); if (la.kind == 52) { GenericInstantiation(gt); } if (gt.Count == 0) { ty = new MapType(false, null, null); } else if (gt.Count != 2) { SemErr("imap type expects two type arguments"); ty = new MapType(false, gt[0], gt.Count == 1 ? new InferredTypeProxy() : gt[1]); } else { ty = new MapType(false, gt[0], gt[1]); } break; } case 5: { Get(); tok = t; gt = null; if (la.kind == 52) { gt = new List<Type>(); GenericInstantiation(gt); } int dims = tok.val.Length == 5 ? 1 : int.Parse(tok.val.Substring(5)); ty = theBuiltIns.ArrayType(tok, dims, gt, true); break; } case 50: { Get(); tok = t; tupleArgTypes = new List<Type>(); if (StartOf(3)) { Type(out ty); tupleArgTypes.Add(ty); while (la.kind == 22) { Get(); Type(out ty); tupleArgTypes.Add(ty); } } Expect(51); if (tupleArgTypes.Count == 1) { // just return the type 'ty' } else { var dims = tupleArgTypes.Count; var tmp = theBuiltIns.TupleType(tok, dims, true); // make sure the tuple type exists ty = new UserDefinedType(tok, BuiltIns.TupleTypeName(dims), dims == 0 ? null : tupleArgTypes); } break; } case 1: { Expression e; tok = t; NameSegmentForTypeName(out e); tok = t; while (la.kind == 27) { Get(); Expect(1); tok = t; List<Type> typeArgs = null; if (la.kind == 52) { typeArgs = new List<Type>(); GenericInstantiation(typeArgs); } e = new ExprDotName(tok, e, tok.val, typeArgs); } ty = new UserDefinedType(e.tok, e); break; } default: SynErr(164); break; } if (la.kind == 30) { Type t2; Get(); tok = t; Type(out t2); if (tupleArgTypes != null) { gt = tupleArgTypes; } else { gt = new List<Type>{ ty }; } ty = new ArrowType(tok, gt, t2); theBuiltIns.CreateArrowTypeDecl(gt.Count); } }
protected bool DeepScanClass(UserDefinedType udt, MemberFilter vis, bool resolveBaseClassIfRequired = true) { bool isBase = false; bool scopeIsInInheritanceHierarchy = udt != null && ctxt.ScopedBlockIsInNodeHierarchy(udt.Definition); bool takeStaticChildrenOnly = ctxt.ScopedBlock is DMethod && (ctxt.ScopedBlock as DMethod).IsStatic; // Check if the scoped node's parent is the current class if(takeStaticChildrenOnly) { takeStaticChildrenOnly = false; var sc = udt.Definition as IBlockNode; while(sc != null) { if(ctxt.ScopedBlock.Parent == sc) { takeStaticChildrenOnly = true; break; } sc = sc.Parent as IBlockNode; } } List<InterfaceType> interfaces = null; while(udt!= null) { if(scanChildren(udt.Definition as DBlockNode, vis, false, isBase, false, takeStaticChildrenOnly, scopeIsInInheritanceHierarchy)) return true; if(udt is TemplateIntermediateType){ var tit = udt as TemplateIntermediateType; var type = (tit.Definition as DClassLike).ClassType; if ((type == DTokens.Struct || type == DTokens.Class || type == DTokens.Template) && HandleAliasThisDeclarations (tit, vis)) return true; if (tit.BaseInterfaces != null) { if (interfaces == null) interfaces = new List<InterfaceType> (); foreach (var I in tit.BaseInterfaces) if (!interfaces.Contains (I)) interfaces.Add (I); } if(resolveBaseClassIfRequired && udt.Base == null && type == DTokens.Class) udt = DResolver.ResolveBaseClasses(udt, ctxt); udt = udt.Base as UserDefinedType; isBase = true; } else break; } if (interfaces != null) foreach (var I in interfaces) if (scanChildren (I.Definition, vis, false, true, false, takeStaticChildrenOnly, scopeIsInInheritanceHierarchy)) return true; return false; }