/// <summary> /// Crea la declaracio del metode 'start' /// </summary> /// <param name="machine">La maquina.</param> /// <returns>La declaracio del metode.</returns> /// private FunctionDeclaration MakeStartFunction(Machine machine) { StatementList bodyStatements = new StatementList(); if (machine.InitializeAction != null) { var statements = MakeActionStatements(machine.InitializeAction); if (statements != null) { bodyStatements.AddRange(statements); } } bodyStatements.Add( new InvokeStatement( new InvokeExpression( new IdentifierExpression("initialize"), new InvokeExpression( new IdentifierExpression("getStateInstance"), new IdentifierExpression( String.Format("StateID::{0}", machine.Start.FullName)))))); return(new FunctionDeclaration( "start", AccessSpecifier.Public, TypeIdentifier.FromName("void"), null, bodyStatements)); }
public Boolean Add( // The Generic ADD String name, iPhone.FileTypes type, TypeIdentifier typeID, String fileInfoText, Byte[] headerBytes, Int32 byteOffset, String imageKey, String tag ) { ItemProperty newItem = new ItemProperty(); newItem.Name = name; newItem.Type = type; newItem.Identifier = typeID; newItem.FileInfoText = fileInfoText; newItem.Header = headerBytes; newItem.ByteOffset = byteOffset; newItem.ImageKey = imageKey; newItem.Tag = tag; items.Add(newItem); selectedIndex = items.Count - 1; return(true); }
public void TypeIdentifier2Test() { var type = Type.GetType("System.Void*"); var ti = new TypeIdentifier(type, null); Assert.AreEqual(0, ti.Describers.Count()); }
private void Set_AssemblyName_SetToNewValue_AssemblyQualifiedNameIsUpdated() { var sut = TypeIdentifier.Parse("System.Linq.IGrouping`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][], System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); sut.AssemblyName = new AssemblyName("MyAssembly, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null"); Assert.Equal("System.Linq.IGrouping`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][], MyAssembly, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null", sut.AssemblyQualifiedName); }
private void Remove_GenericArgument_AssemblyQualifiedNameIsUpdated() { var sut = TypeIdentifier.Parse("System.Linq.IGrouping`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][], System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); sut.GenericArguments.RemoveAt(0); Assert.Equal("System.Linq.IGrouping`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]][], System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", sut.AssemblyQualifiedName); }
private void GenericArguments_VariousTypeNames_ReturnsExpectedValue(string input, ExpectedData data) { var sut = TypeIdentifier.Parse(input); Assert.NotNull(sut.GenericArguments); Assert.Equal(data.GenericArguments, sut.GenericArguments.Select(arg => new ExpectedData(arg))); }
public ProxyInfo FindTypeProxy(TypeIdentifier identifier) { ProxyInfo proxy; TypeProxies.TryGetValue(identifier, out proxy); return(proxy); }
public PropertyIdentifier(string name, bool hasGet, bool hasSet, TypeIdentifier typeId) : base(name) { this.typeId = typeId; HasGet = hasGet; HasSet = hasSet; }
/// <summary> /// Creates a DataGridColumn derived ModelItem /// </summary> internal static ModelItem CreateColumnFromColumnType(EditingContext context, TypeIdentifier dataGridColumnTypeId, ColumnInfo columnGenerationInfo) { ModelItem dataGridColumn = ModelFactory.CreateItem(context, dataGridColumnTypeId); if (columnGenerationInfo.HeaderFromAttribute == null) { // Default the Header to the property name if there's no attribute tied to it dataGridColumn.Properties[PlatformTypes.DataGridColumn.HeaderProperty].SetValue(columnGenerationInfo.PropertyInfo.Name); } if (dataGridColumnTypeId == PlatformTypes.DataGridTemplateColumn.TypeId) { return CreateTemplateColumn(context, columnGenerationInfo, dataGridColumn); } ModelItem binding = ModelFactory.CreateItem(context, PlatformTypes.Binding.TypeId); binding.Properties[PlatformTypes.Binding.PathProperty].SetValue(columnGenerationInfo.PropertyInfo.Name); // ReadOnly Properties are handled by the runtime so we don't need to alter the Binding here // to account for them. // Whether or not a column can sort is handled by the runtime as well dataGridColumn.Properties[PlatformTypes.DataGridBoundColumn.BindingProperty].SetValue(binding); return dataGridColumn; }
public static DeclaredType Unresolved(TypeIdentifier typeIdentifier, Type declaration, Namespace ns) { var declaredType = new DeclaredType(typeIdentifier, ns) { IsResolved = false, declaration = declaration }; if (declaration.BaseType != null) { declaredType.ParentType = Unresolved( IdentifierFor.Type(declaration.BaseType), declaration.BaseType, Namespace.Unresolved(IdentifierFor.Namespace(declaration.BaseType.Namespace))); } IEnumerable <Type> interfaces = GetInterfaces(declaration); foreach (Type face in interfaces) { declaredType.Interfaces.Add( Unresolved(IdentifierFor.Type(face), face, Namespace.Unresolved(IdentifierFor.Namespace(face.Namespace)))); } return(declaredType); }
public CollectionInitializer(TypeIdentifier type, int dimension, int size) { this.type = type; this.dimension = dimension; this.size = size; this.initFromStack = true; }
public static DeclaredType Unresolved(TypeIdentifier typeIdentifier, Namespace ns) { return(new DeclaredType(typeIdentifier, ns) { IsResolved = false }); }
public Parameter(ParameterModifier modifier, TypeIdentifier type, Identifier identifier, Expression defaultValue) { Modifier = modifier; Type = type; Identifier = identifier; DefaultVaue = defaultValue; }
public override bool Equals(object obj) { return(obj is NetworkPacket entity && EqualityComparer <Uri> .Default.Equals(Source, entity.Source) && TypeIdentifier.Equals(entity.TypeIdentifier) && EqualityComparer <object> .Default.Equals(Entity, entity.Entity)); }
public static DeclaredType Unresolved(TypeIdentifier typeIdentifier, Type type, Namespace ns) { var declaredType = new DeclaredType(typeIdentifier, ns) { IsResolved = false, representedType = type }; if (type.BaseType != null) { declaredType.ParentType = Unresolved( Identifier.FromType(type.BaseType), type.BaseType, Namespace.Unresolved(Identifier.FromNamespace(type.BaseType.Namespace))); } IEnumerable <Type> interfaces = GetInterfaces(type); foreach (Type face in interfaces) { declaredType.Interfaces.Add( Unresolved( Identifier.FromType(face), face, Namespace.Unresolved(Identifier.FromNamespace(face.Namespace)))); } return(declaredType); }
public TypeInfo GetTypeInformation(TypeReference type) { if (type == null) { throw new ArgumentNullException("type"); } TypeInfo result; var typedef = TypeUtil.GetTypeDefinition(type); if (typedef == null) { return(null); } var identifier = new TypeIdentifier(typedef); if (TypeInformation.TryGet(identifier, out result)) { return(result); } var args = new MakeTypeInfoArgs(); EnqueueType(args.TypesToInitialize, type); // We must construct type information in two passes, so that method group construction // behaves correctly and ignores all the right methods. // The first pass walks all the way through the type graph (starting with the current type), // ensuring we have type information for all the types in the graph. We do this iteratively // to avoid overflowing the stack. // After we have type information for all the types in the graph, we then walk over all // the types again, and construct their method groups, since we have the necessary // information to determine which methods are ignored. while (args.TypesToInitialize.Count > 0) { var kvp = args.TypesToInitialize.First; args.TypesToInitialize.Remove(kvp.Key); args.Definition = kvp.Value; TypeInformation.TryCreate( kvp.Key, args, MakeTypeInfo ); } foreach (var ti in args.SecondPass.Values) { ti.Initialize(); ti.ConstructMethodGroups(); } if (!TypeInformation.TryGet(identifier, out result)) { return(null); } else { return(result); } }
/// <summary> /// Creates a DataGridColumn derived ModelItem /// </summary> internal static ModelItem CreateColumnFromColumnType(EditingContext context, TypeIdentifier dataGridColumnTypeId, ColumnInfo columnGenerationInfo) { ModelItem dataGridColumn = ModelFactory.CreateItem(context, dataGridColumnTypeId); if (columnGenerationInfo.HeaderFromAttribute == null) { // Default the Header to the property name if there's no attribute tied to it dataGridColumn.Properties[PlatformTypes.DataGridColumn.HeaderProperty].SetValue(columnGenerationInfo.PropertyInfo.Name); } if (dataGridColumnTypeId == PlatformTypes.DataGridTemplateColumn.TypeId) { return(CreateTemplateColumn(context, columnGenerationInfo, dataGridColumn)); } ModelItem binding = ModelFactory.CreateItem(context, PlatformTypes.Binding.TypeId); binding.Properties[PlatformTypes.Binding.PathProperty].SetValue(columnGenerationInfo.PropertyInfo.Name); // ReadOnly Properties are handled by the runtime so we don't need to alter the Binding here // to account for them. // Whether or not a column can sort is handled by the runtime as well dataGridColumn.Properties[PlatformTypes.DataGridBoundColumn.BindingProperty].SetValue(binding); return(dataGridColumn); }
public void UpdateFrom(RegistrationSourceAddedMessage message) { _registrationSources.Add(new RegistrationSource( message.RegistrationSource.Id, TypeIdentifier.Parse(message.RegistrationSource.TypeAssemblyQualifiedName), FormatDescription(message.RegistrationSource.Description))); }
/// <summary> /// Starts reading the next object. /// </summary> /// <param name="name">Name of the variable.</param> /// <returns>Returns the type of the next object.</returns> public Type BeginReadObject(string name) { TypeIdentifier ti = (TypeIdentifier)reader.ReadByte(); switch (ti) { case TypeIdentifier.Double: return(typeof(double)); case TypeIdentifier.Float: return(typeof(float)); case TypeIdentifier.Int16: return(typeof(short)); case TypeIdentifier.Int32: return(typeof(int)); case TypeIdentifier.String: return(typeof(string)); case TypeIdentifier.Object: int typeId = ReadInt(null); return(Serializer.Instance.GetTypeFromId(typeId)); default: throw new NotSupportedException("Not supported so far! " + ti.ToString()); } }
private void Set_FullName_TypeWithoutGenericArguments_GenericArgumentsIsCorrectlyUpdated() { var sut = TypeIdentifier.Parse("ConsoleApp10.Root+Nested+Nested2[System.Int32][], ConsoleApp10, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); sut.FullName = "System.Foo[]"; Assert.Empty(sut.GenericArguments); }
public void ShouldReturnClassMetadataNameWhenNodeIsKindParameter() { // Given var nodeKind = SyntaxKind.Parameter; var classMetadataName = "class-metadata-name"; var expected = classMetadataName; var nodeMock = new Mock <Node>(); var classMetadata = new ClassMetadata { Name = classMetadataName, }; nodeMock.SetupGet( mock => mock.Kind ).Returns( nodeKind ); // When var actual = TypeIdentifier.Identify( nodeMock.Object, classMetadata ); // Then actual.Should().Be(expected); }
private void GetElementType_MultiArray_ReturnsSingleArray() { var sut = TypeIdentifier.Parse("System.Int32[][,], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); var actual = sut.GetElementType(); Assert.NotNull(actual); Assert.Equal(SystemIntArray, new ExpectedData(actual)); }
/// <summary> /// Constructs a Delphi type name for a type that represents a protobuf message type or enum type. /// </summary> /// <param name="typeName">The protobuf type's name</param> /// <returns>The Delphi type name</returns> internal static string ConstructDelphiTypeName(string typeName) { if (!typeName.StartsWith(".")) { return(TypeIdentifier.Generate(typeName, reservedIdentifiers: ReservedIdentifiers)); } string[] typeNameSegments = typeName.Split(".", StringSplitOptions.RemoveEmptyEntries).ToArray(); string unqualifiedName = ConstructDelphiTypeName(typeNameSegments[^ 1]);
public static Type ResolveType(EditingContext context, TypeIdentifier typeIdentifier) { if (context == null) { throw new ArgumentNullException("context"); } return(context.Services.GetRequiredService <ModelService>().InvokeResolveType(typeIdentifier)); }
public Array(TypeIdentifier initializatorType, int size) { this.InitializatorType = initializatorType; this.size = size; rep = new List<BaseType>(size); this._type = new TypeIdentifier { TypeEnum = TypeEnum.Array, GenericType = initializatorType }; InitializeArray(); }
/// <summary> /// Crea la declaracio del metode 'end'. /// </summary> /// <param name="machine">La maquina.</param> /// <returns>La declaracio del metode.</returns> /// private FunctionDeclaration MakeEndFunction(Machine machine) { return(new FunctionDeclaration { Name = "end", ReturnType = TypeIdentifier.FromName("void"), Access = AccessSpecifier.Public }); }
public CollectionInitializer(TypeIdentifier type, int dimension) { this.type = type; //this.size = size; //this.dimension = 1; this.dimension = dimension; readSizesFromStack = true; this.initFromStack = true; }
/// <summary> /// Crea la declaracio de la variable 'owner' /// </summary> /// <param name="machine">La maquina.</param> /// <returns>La declaracio de la variable.</returns> /// private VariableDeclaration MakeOwnerVariable(Machine machine) { return(new VariableDeclaration( "owner", AccessSpecifier.Private, ImplementationSpecifier.Instance, TypeIdentifier.FromName(String.Format("{0}*", ownerClassName)), null)); }
public MethodIdentifier(string name, TypeIdentifier[] parameters, bool isStatic, bool isPublic, TypeIdentifier typeId) : base(name) { this.typeId = typeId; this.parameters = parameters; this.isStatic = isStatic; this.isPublic = isPublic; }
/// <summary> /// Construeix la funcio de transicio. /// </summary> /// <param name="state">El estat.</param> /// <param name="transitionName">El nom de la transicio.</param> /// <returns>La funcio.</returns> /// private FunctionDeclaration MakeOnTransitionFunction(State state, string transitionName, string contextClassName, string ownerClassName) { StatementList bodyStatements = new StatementList(); // Intruccio per recuperar el context. // bodyStatements.Add( new InlineStatement( String.Format("{0}* ctx = static_cast<{0}*>(getContext())", contextClassName))); bodyStatements.Add( new InlineStatement( String.Format("{0}* owner = ctx->getOwner()", ownerClassName))); foreach (Transition transition in state.Transitions) { if (transition.TransitionEvent.Name == transitionName) { StatementList trueBodyStatements = new StatementList(); trueBodyStatements.Add(new InvokeStatement( new InvokeExpression( new IdentifierExpression("ctx->beginTransition")))); // Accio de transicio. // if (transition.Action != null) { trueBodyStatements.AddRange(MakeActionStatements(transition.Action)); } trueBodyStatements.Add(new InvokeStatement( new InvokeExpression( new IdentifierExpression("ctx->endTransition"), new InvokeExpression( new IdentifierExpression("ctx->getStateInstance"), new IdentifierExpression( String.Format("Context::StateID::{0}", transition.NextState.Name)))))); Expression conditionExpr = new InlineExpression(transition.Guard == null ? "true" : transition.Guard.Expression); bodyStatements.Add(new IfThenElseStatement( conditionExpr, new BlockStatement { Statements = trueBodyStatements }, null)); } } return(new FunctionDeclaration { Access = AccessSpecifier.Public, Implementation = ImplementationSpecifier.Override, ReturnType = TypeIdentifier.FromName("void"), Name = String.Format("transition_{0}", transitionName), Body = new BlockStatement(bodyStatements), }); }
public Declare(string name, TypeEnum type) { this.type = new TypeIdentifier { TypeEnum = type, TypeName = type.ToString() }; this.name = name; }
/// <summary> /// Converts a basetype value to the given type. /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <returns></returns> public static BaseType Convert(BaseType value, TypeIdentifier targetType) { if (targetType.TypeEnum == TypeEnum.Undefined || targetType == value.Type) { return value; } var target = CreateValue(targetType); target.Assign(value); return target; }
/// <summary> /// Create a DataTemplate for the given control bound to the given data source property /// </summary> internal static ModelItem CreateDataTemplate(EditingContext context, TypeIdentifier controlToTemplateTypeId, PropertyIdentifier controlPropertyId, string datasourcePropertyName) { ModelItem controlToTemplate = ModelFactory.CreateItem(context, controlToTemplateTypeId); ModelItem controlBinding = ModelFactory.CreateItem(context, PlatformTypes.Binding.TypeId); controlBinding.Properties[PlatformTypes.Binding.PathProperty].SetValue(datasourcePropertyName); controlToTemplate.Properties[controlPropertyId].SetValue(controlBinding); ModelItem dataTemplate = ModelFactory.CreateItem(context, PlatformTypes.DataTemplate.TypeId); dataTemplate.Content.SetValue(controlToTemplate); return dataTemplate; }
private void CheckAndAddLocalVariable(string name, TypeIdentifier ti, NodeValueInfo nvi) { if (IsExistsLocalVariable(name)) AddWarning(CompilerErrorCode.LocalVariableNameCollision, string.Format("Local variable name \"{0}\" is already exist in the current scope.", name), nvi); else AddLocalVariable(name, ti, nvi); }
public Declare(string name, TypeIdentifier ti) { this.name = name; type = ti; }
public GlobalVariableInfo(string name, TypeIdentifier ti, BaseType value, string fileName, NodeValueInfo nvi) : base(name,ti,fileName,nvi) { Value = value; }
public override TypeName NestedName (TypeIdentifier innerName) { return TypeNames.FromDisplay(DisplayName + "+" + innerName.DisplayName); }
void AddName (string type_name) { if (name == null) { name = ParsedTypeIdentifier(type_name); } else { if (nested == null) nested = new List <TypeIdentifier> (); nested.Add (ParsedTypeIdentifier(type_name)); } }
public void EmitMain() { var typeId = new TypeIdentifier(Assembly.EntryPoint.DeclaringType); var memberId = new MemberIdentifier(Translator.TypeInfoProvider, Assembly.EntryPoint); var entryPointIdentifier = new QualifiedMemberIdentifier(typeId, memberId); var mainExpression = Translator.FunctionCache.GetExpression(entryPointIdentifier); var astEmitter = (AstEmitter)EntryPointAstEmitter; var mainEmitter = new AstEmitter(this, Formatter, astEmitter.JSIL, astEmitter.TypeSystem, astEmitter.TypeInfo, astEmitter.Configuration, isTopLevel: true); Switch(PrecedingType.TopLevel); if (NeedStaticInit) { Formatter.ConditionalNewLine(); Formatter.WriteRaw("(invoke \"__static_init\")"); Formatter.NewLine(); Formatter.NewLine(); } var body = mainExpression.Body; foreach (var stmt in body.Statements) { mainEmitter.Visit(stmt); Formatter.ConditionalNewLine(); } }
public VariableInfo(string name, TypeIdentifier ti, string fileName, NodeValueInfo nvi) : base(fileName, nvi) { Name = name; Type = ti; }
public override void Visit(CollectionInitializatorNode node) { // Collection Type node.CollectionType.Accept(this); // Collection Type TypeIdentifier collectionType = lastCompiledDataType; string collectionTypeName = lastCompiledDataTypeName; // IsArray init bool isArray = false; if (node.CollectionType.Children.Count == 2) isArray = true; // Array Dimension int arrayDim = lastCompiledDimensionCount; // Collection Count int collectionCount = node.CollectionElementList.Count; // Set the type identifier if (isArray) { collectionType = new TypeIdentifier { TypeEnum = TypeEnum.Array, GenericType = collectionType, Dimensions = new List<int> { collectionCount } }; } node.CollectionElementList.Reverse(); foreach (var item in node.CollectionElementList) item.Accept(this); node.CollectionElementList.Reverse(); AddCommand(new CollectionInitializer(collectionType, 1, collectionCount)); }
public Boolean AddFolder( // for FileName and Extension String name, TypeIdentifier typeID, String folderInfoText, String imageKey, String tag ) { return Add(name, iPhone.FileTypes.Folder, typeID, folderInfoText, nullBytes, 0, imageKey, tag); }
public Boolean AddFile( // for ExtHeadString and ExtHeadBytes String name, TypeIdentifier typeID, String extension, String headerString, Int32 byteOffset, String imageKey, String tag ) { Byte[] headerBytes; if (typeID == TypeIdentifier.ExtHeadString) { headerBytes = TextString.ToByte(headerString); } else { headerBytes = Hex.ToBytes(headerString); } return Add(name, iPhone.FileTypes.File, typeID, extension, headerBytes, byteOffset, imageKey, tag); }
public Boolean AddFile( // for FileName, Extension, and FullPath String name, TypeIdentifier typeID, String fileInfoText, String imageKey, String tag ) { return Add(name, iPhone.FileTypes.File, typeID, fileInfoText, nullBytes, 0, imageKey, tag); }
public Boolean Add( // The Generic ADD String name, iPhone.FileTypes type, TypeIdentifier typeID, String fileInfoText, Byte[] headerBytes, Int32 byteOffset, String imageKey, String tag ) { ItemProperty newItem = new ItemProperty(); newItem.Name = name; newItem.Type = type; newItem.Identifier = typeID; newItem.FileInfoText = fileInfoText; newItem.Header = headerBytes; newItem.ByteOffset = byteOffset; newItem.ImageKey = imageKey; newItem.Tag = tag; items.Add(newItem); selectedIndex = items.Count - 1; return true; }
public override void Visit(VariableDeclarationNode node) { RegisterIntervalChange(node); // Type node.VariableType.Accept(this); // If this is UserDefined, then use lastCompiledUserDefinedDataTypeName TypeEnum varType = lastCompiledDataType; string varTypeName = lastCompiledDataTypeName; int varDimensionCount = lastCompiledDimensionCount; // Name string varName = node.VariableName.Value; // Declare if (varType != TypeEnum.Undefined) { if (varDimensionCount > 0) AddCommand(new ArrayDeclare(varName, varType, varDimensionCount)); else AddCommand(new Declare(varName, varType)); } else { if (varDimensionCount > 0) { //AddCommand(new ArrayDeclare(varName, TypeEnum.UserDefinedType, varDimensionCount)); // AddError(CompilerErrorCode.Custom, string.Format("User defined array types is not supported yet! ({0})", varTypeName), node.NodeValueInfo); // Checked in the semantic analiser } else { var ti = new TypeIdentifier { TypeEnum = TypeEnum.UserDefinedType, TypeName = varTypeName, UserDefinedType = DTO.Program.Program.GetUserDefinedType(varTypeName) }; AddCommand(new Declare(varName, ti)); } } }
private void AddLocalVariable(string name, TypeIdentifier ti, NodeValueInfo nvi) { if (currentLocalVariableList.Count == 0) NewScope(); currentLocalVariableList.Last<List<VariableInfo>>().Add(new VariableInfo(name, ti, SourceFileName, nvi)); }
public UserDefinedTypeInfo(TypeIdentifier ti, string fileName, NodeValueInfo nvi) : base(fileName, nvi) { Type = ti; }
public override void Visit(VariableDeclarationNode node) { // Type node.VariableType.Accept(this); // If this is UserDefined, then use lastCompiledUserDefinedDataTypeName TypeEnum varType = lastCompiledDataType; string varTypeName = lastCompiledDataTypeName; int varDimensionCount = lastCompiledDimensionCount; // Name string varName = node.VariableName.Value; // Check variable name if (varType != TypeEnum.Undefined) { ChecktVariable(node, varType, varTypeName, varDimensionCount, varName); } else { if (varDimensionCount > 0) { AddError(CompilerErrorCode.Custom, string.Format("User defined array types is not supported yet! ({0})", varTypeName), node.NodeValueInfo); } else { var ti = new TypeIdentifier { TypeEnum = TypeEnum.UserDefinedType, TypeName = varTypeName, UserDefinedType = DTO.Program.Program.GetUserDefinedType(varTypeName) }; CheckAndAddLocalVariable(varName, ti, node.NodeValueInfo); } } }
/// <summary> /// Takes a platform neutral TypeIdentifier and returns back a platform specific Type. /// For each of the types you are providing a design experience for, you must add an entry to this method. /// </summary> /// <param name="id"></param> /// <returns></returns> public Type GetPlatformType(TypeIdentifier id) { //System.IO.File.AppendAllText(@"C:\Temp\DesignDebug.txt", "GetPlatformType: " + id.Name); switch (id.Name) { case ExpanzControlsEnum.ActivityPanelEx: return SilverlightTypes.ActivityPanelExControlType; case ExpanzControlsEnum.ApplicationNavigationMenu: return SilverlightTypes.ApplicationNavigationMenuControlType;; case ExpanzControlsEnum.BusyIndicatorEx: return SilverlightTypes.BusyIndicatorExControlType; case ExpanzControlsEnum.ButtonEx: return SilverlightTypes.ButtonExControlType; case ExpanzControlsEnum.CheckBoxEx: return SilverlightTypes.CheckBoxExControlType; case ExpanzControlsEnum.ChildWindowEx: return SilverlightTypes.ChildWindowExControlType; case ExpanzControlsEnum.ClientMessageWindow: return SilverlightTypes.ClientMessageWindowControlType; case ExpanzControlsEnum.CloseButton: return SilverlightTypes.CloseButtonControlType; case ExpanzControlsEnum.ComboBoxEx: return SilverlightTypes.ComboBoxExControlType; case ExpanzControlsEnum.ComboBoxItemEx: return SilverlightTypes.ComboBoxItemExControlType; case ExpanzControlsEnum.ContentContainer: return SilverlightTypes.ContentContainerControlType; case ExpanzControlsEnum.ContextMenuButton: return SilverlightTypes.ContextMenuButtonControlType; case ExpanzControlsEnum.DataGridEx: return SilverlightTypes.DataGridExControlType; case ExpanzControlsEnum.DatePickerEx: return SilverlightTypes.DatePickerExControlType; case ExpanzControlsEnum.HelperButton: return SilverlightTypes.HelperButtonControlType; case ExpanzControlsEnum.HyperlinkButtonEx: return SilverlightTypes.HyperlinkButtonExControlType; case ExpanzControlsEnum.LabelEx: return SilverlightTypes.LabelExControlType; case ExpanzControlsEnum.LaunchActivityButton: return SilverlightTypes.LaunchActivityButtonControlType; case ExpanzControlsEnum.LaunchActivityHyperlinkButton: return SilverlightTypes.LaunchActivityHyperlinkButtonControlType; case ExpanzControlsEnum.ListBoxEx: return SilverlightTypes.ListBoxExControlType; case ExpanzControlsEnum.ListBoxItemEx: return SilverlightTypes.ListBoxItemExControlType; case ExpanzControlsEnum.LoginForm: return SilverlightTypes.LoginFormControlType; case ExpanzControlsEnum.MessagePanel: return SilverlightTypes.MessagePanelControlType; case ExpanzControlsEnum.PageEx: return SilverlightTypes.PageExControlType; case ExpanzControlsEnum.PropertiesButton: return SilverlightTypes.PropertiesButtonControlType; case ExpanzControlsEnum.RadioButtonColumn: return SilverlightTypes.RadioButtonColumnControlType; //case ExpanzControlsEnum.TextBlockEx: // return SilverlightTypes.TextBlockExControlType; case ExpanzControlsEnum.TextBoxEx: return SilverlightTypes.TextBoxExControlType; //case ExpanzControlsEnum.TrafficDebugButton: // return SilverlightTypes.TrafficDebugButtonwControlType; case ExpanzControlsEnum.TrafficDebuggingWindow: return SilverlightTypes.TrafficDebuggingWindowControlType; case ExpanzControlsEnum.UserControlEx: return SilverlightTypes.UserControlExControlType; //case ExpanzControlsEnum.ValidationSummaryEx: //return SilverlightTypes.ValidationSummaryExControlType; } throw new ArgumentOutOfRangeException("id.Name", id.Name, "Control has no corresponding enumeration"); }
public PanelParentAdapter(TypeIdentifier targetPanelType) { _targetPanelType = targetPanelType; }
public override BaseType ConvertTo(TypeIdentifier type) { return referencedValue.ConvertTo(type); }
public async Task<MutationResult> ExecuteMutation(Mutant mutant, CciModuleSource moduleSource) { var type = new TypeIdentifier((INamedTypeDefinition) mutant.MutationTarget.ProcessingContext.Type.Object); var method = new MethodIdentifier((IMethodDefinition) mutant.MutationTarget.ProcessingContext.Method.Object); var filter = new MutationFilter(type.InList(), method.InList()); _log.Debug("ExecuteMutation of: " + type+" - " +method ); IMutationOperator mutationOperator = mutant.MutationTarget.OperatorId == null ? new IdentityOperator() : _mutOperators.Single(m => mutant.MutationTarget.OperatorId == m.Info.Id); var cci = moduleSource; try { _log.Info("Execute mutation of " + mutant.MutationTarget + " contained in " + mutant.MutationTarget.MethodRaw + " modules. "); var mutatedModules = new List<IModuleInfo>(); var module = moduleSource.Modules.Single(); var visitorBack = new VisualCodeVisitorBack(mutant.MutationTarget.InList(), _sharedTargets.GetValues(mutationOperator, returnEmptySet: true), module.Module, mutationOperator.Info.Id); var traverser2 = new VisualCodeTraverser(_filter, visitorBack, moduleSource); traverser2.Traverse(module.Module); visitorBack.PostProcess(); var operatorCodeRewriter = mutationOperator.CreateRewriter(); var rewriter = new VisualCodeRewriter(cci.Host, visitorBack.TargetAstObjects, visitorBack.SharedAstObjects, _filter, operatorCodeRewriter, traverser2); operatorCodeRewriter.MutationTarget = new UserMutationTarget(mutant.MutationTarget.Variant.Signature, mutant.MutationTarget.Variant.AstObjects); operatorCodeRewriter.NameTable = cci.Host.NameTable; operatorCodeRewriter.Host = cci.Host; operatorCodeRewriter.Module = module.Module; operatorCodeRewriter.OperatorUtils = _operatorUtils; operatorCodeRewriter.Initialize(); var rewrittenModule = rewriter.Rewrite(module.Module); rewriter.CheckForUnfoundObjects(); mutant.MutationTarget.Variant.AstObjects = null; //TODO: avoiding leaking memory. refactor mutatedModules.Add(new ModuleInfo(rewrittenModule, "")); List<ICciModuleSource> cci1 = new List<ICciModuleSource>(); cci1.Add(cci); List<IMethodDefinition> methodMutated = new List<IMethodDefinition>(); methodMutated.Add(mutant.MutationTarget.MethodMutated); var result = new MutationResult(mutant, cci/*1*/, null, mutant.MutationTarget.MethodMutated); mutant.MutationTarget.MethodMutated = null; //TODO: avoiding leaking memory. refactor return result; } catch (Exception e) { throw new MutationException("CreateMutants failed on operator: {0}.".Formatted(mutationOperator.Info.Name), e); } }
/// <summary> /// Creates a BaseType value from the given typeEnum. /// </summary> /// <param name="type"></param> /// <returns></returns> public static BaseType CreateValue(TypeIdentifier type) { switch (type.TypeEnum) { // Primitive Types case TypeEnum.Void: return null; case TypeEnum.Integer: return new Integer(); case TypeEnum.Character: return new Character(); case TypeEnum.String: return new String(); case TypeEnum.Decimal: return new Decimal(); case TypeEnum.Float: return new Float(); case TypeEnum.Boolean: return new Boolean(); // Complex Types case TypeEnum.Array: return new Array(type.GenericType, type.Dimensions[0]); case TypeEnum.List: return new List(); case TypeEnum.Set: return new Set(); case TypeEnum.Stack: return new Stack(); case TypeEnum.Queue: return new Queue(); case TypeEnum.PriorityQueue: return new PriorityQueue(); case TypeEnum.Point: return new Point(); //case TypeEnum.Iterator: // return new Iterator( case TypeEnum.Tree: return new Tree(); case TypeEnum.BinaryTree: return new BinaryTree(); case TypeEnum.Null: return new Null(); // User Defined Types case TypeEnum.UserDefinedType: return type.UserDefinedType.CreateAnInstance(); default: throw new Exceptions.PsimulexCoreException(string.Format("Cannot create value of type {0}.", type)); } }