public void DefineVariables() { variables = new List <Tuple <string, EnumTypes, string> >(); currentToken = tokens.First; nextToken = currentToken.Next; previousToken = currentToken.Previous; while (currentToken.Next != null) { if (currentToken.Value.Value.Equals("var")) { string name = GetVariableName(currentToken); EnumTypes type = GetVariableType(currentToken); dynamic value = GetVariableValue(currentToken); Tuple <string, EnumTypes, string> variable = new Tuple <string, EnumTypes, string>(name, type, value); //output.Text += variable.Item1 + " "; //output.Text += variable.Item2.ToString() + " "; //output.Text += variable.Item3 + " "; //output.Text += "\n"; variables.Add(variable); } currentToken = nextToken; nextToken = currentToken.Next; previousToken = currentToken.Previous; } }
/// <inheritdoc /> public override EnumTypeConfiguration AddEnumType(Type type) { if (type == null) { throw Error.ArgumentNull("type"); } if (!TypeHelper.IsEnum(type)) { throw Error.Argument("type", SRResources.TypeCannotBeEnum, type.FullName); } EnumTypeConfiguration enumTypeConfiguration = EnumTypes.SingleOrDefault(e => e.ClrType == type); if (enumTypeConfiguration == null) { enumTypeConfiguration = base.AddEnumType(type); foreach (object member in Enum.GetValues(type)) { bool addedExplicitly = enumTypeConfiguration.Members.Any(m => m.Name.Equals(member.ToString())); EnumMemberConfiguration enumMemberConfiguration = enumTypeConfiguration.AddMember((Enum)member); enumMemberConfiguration.AddedExplicitly = addedExplicitly; } ApplyEnumTypeConventions(enumTypeConfiguration); } return(enumTypeConfiguration); }
/// <inheritdoc /> public override EnumTypeConfiguration AddEnumType(Type type) { if (type == null) { throw Error.ArgumentNull("type"); } if (!type.IsEnum) { throw Error.Argument("type", SRResources.TypeCannotBeEnum, type.FullName); } EnumTypeConfiguration enumTypeConfiguration = EnumTypes.SingleOrDefault(e => e.ClrType == type); if (enumTypeConfiguration == null) { enumTypeConfiguration = base.AddEnumType(type); foreach (object member in Enum.GetValues(type)) { enumTypeConfiguration.AddMember((Enum)member); } } return(enumTypeConfiguration); }
public void FixupRelationships() { var additionalBehaviors = AdditionalBehaviors.ToDictionary(x => x.Id); var entityTypes = EntityTypes.ToDictionary(x => x.Id); var dataTypes = DataTypes.ToDictionary(x => x.Id); var entityTypeFacetDefaultValues = EntityTypeFacetDefaultValues.ToDictionary(x => x.Id); var entityTypeFacetDefinitions = EntityTypeFacetDefinitions.ToDictionary(x => x.Id); var entityTypeFacetValues = EntityTypeFacetValues.ToDictionary(x => x.Id); var entityTypeGeneralUsageCategories = EntityTypeGeneralUsageCategories.ToDictionary(x => x.Id); var enumTypes = EnumTypes.ToDictionary(x => x.Id); var enumValues = EnumValues.ToDictionary(x => x.Id); var expressionDefinitions = ExpressionDefinitions.ToDictionary(x => x.Id); var expressionBodies = ExpressionBodies.ToDictionary(x => x.Id); var facetTypes = FacetTypes.ToDictionary(x => x.Id); var properties = Properties.ToDictionary(x => x.Id); var propertyBehaviors = PropertyBehaviors.ToDictionary(x => x.Id); var propertyFacetDefaultValues = PropertyFacetDefaultValues.ToDictionary(x => x.Id); var propertyFacetDefinitions = PropertyFacetDefinitions.ToDictionary(x => x.Id); var propertyFacetValues = PropertyFacetValues.ToDictionary(x => x.Id); var propertyGeneralUsageCategories = PropertyGeneralUsageCategories.ToDictionary(x => x.Id); Fixup(PropertyFacetValues, properties, nameof(PropertyFacetValue.PropertyId), nameof(PropertyFacetValue.Property), nameof(Property.PropertyFacetValues)); Fixup(PropertyFacetValues, propertyFacetDefinitions, nameof(PropertyFacetValue.FacetDefinitionId), nameof(PropertyFacetValue.FacetDefinition)); Fixup(PropertyFacetDefinitions, facetTypes, nameof(PropertyFacetDefinition.FacetTypeId), nameof(PropertyFacetDefinition.FacetType)); Fixup(PropertyFacetDefinitions, enumTypes, nameof(PropertyFacetDefinition.EnumTypeId), nameof(PropertyFacetDefinition.EnumType)); Fixup(PropertyFacetDefaultValues, propertyFacetDefinitions, nameof(PropertyFacetDefaultValue.FacetDefinitionId), nameof(PropertyFacetDefaultValue.FacetDefinition)); Fixup(PropertyFacetDefaultValues, propertyGeneralUsageCategories, nameof(PropertyFacetDefaultValue.GeneralUsageCategoryId), nameof(PropertyFacetDefaultValue.GeneralUsageCategory)); Fixup(Properties, entityTypes, nameof(Property.OwnerEntityTypeId), nameof(Property.OwnerEntityType), nameof(EntityType.Properties)); Fixup(Properties, propertyGeneralUsageCategories, nameof(Property.GeneralUsageCategoryId), nameof(Property.GeneralUsageCategory)); Fixup(Properties, dataTypes, nameof(Property.DataTypeId), nameof(Property.DataType)); Fixup(Properties, expressionDefinitions, nameof(Property.ExpressionDefinitionId), nameof(Property.ExpressionDefinition)); Fixup(Properties, entityTypes, nameof(Property.DataEntityTypeId), nameof(Property.DataEntityType)); Fixup(Properties, properties, nameof(Property.ForeignKeyPropertyId), nameof(Property.ForeignKeyProperty), nameof(Property.Unused1)); Fixup(Properties, properties, nameof(Property.InversePropertyId), nameof(Property.InverseProperty), nameof(Property.Unused2)); Fixup(PropertyBehaviors, properties, nameof(PropertyBehavior.PropertyId), nameof(PropertyBehavior.Property), nameof(Property.PropertyBehaviors)); Fixup(PropertyBehaviors, additionalBehaviors, nameof(PropertyBehavior.AdditionalBehaviorId), nameof(PropertyBehavior.AdditionalBehavior)); Fixup(ExpressionDefinitions, entityTypes, nameof(ExpressionDefinition.MainInputEntityTypeId), nameof(ExpressionDefinition.MainInputEntityType)); Fixup(ExpressionDefinitions, expressionBodies, nameof(ExpressionDefinition.ActiveBodyId), nameof(ExpressionDefinition.ActiveBody)); Fixup(ExpressionBodies, expressionDefinitions, nameof(ExpressionBody.DefinitionId), nameof(ExpressionBody.Definition), nameof(ExpressionDefinition.Bodies)); Fixup(EnumValues, enumTypes, nameof(EnumValue.EnumTypeId), nameof(EnumValue.EnumType), nameof(EnumType.Values)); Fixup(EntityTypes, entityTypeGeneralUsageCategories, nameof(EntityType.GeneralUsageCategoryId), nameof(EntityType.GeneralUsageCategory)); Fixup(EntityTypes, entityTypes, nameof(EntityType.BaseEntityTypeId), nameof(EntityType.BaseEntityType)); Fixup(EntityTypeFacetValues, entityTypes, nameof(EntityTypeFacetValue.EntityTypeId), nameof(EntityTypeFacetValue.EntityType), nameof(EntityType.FacetValues)); Fixup(EntityTypeFacetValues, entityTypeFacetDefinitions, nameof(EntityTypeFacetValue.FacetDefinitionId), nameof(EntityTypeFacetValue.FacetDefinition)); Fixup(EntityTypeFacetDefinitions, facetTypes, nameof(EntityTypeFacetDefinition.FacetTypeId), nameof(EntityTypeFacetDefinition.FacetType)); Fixup(EntityTypeFacetDefinitions, enumTypes, nameof(EntityTypeFacetDefinition.EnumTypeId), nameof(EntityTypeFacetDefinition.EnumType)); Fixup(EntityTypeFacetDefaultValues, entityTypeFacetDefinitions, nameof(EntityTypeFacetDefaultValue.FacetDefinitionId), nameof(EntityTypeFacetDefaultValue.FacetDefinition)); Fixup(EntityTypeFacetDefaultValues, entityTypeGeneralUsageCategories, nameof(EntityTypeFacetDefaultValue.GeneralUsageCategoryId), nameof(EntityTypeFacetDefaultValue.GeneralUsageCategory)); }
public void AddZDescType(IZDescType descType) { if (descType is ZDimType) { DimTypes.Add(descType as ZDimType); } else if (descType is ZEnumType) { ZEnumType zenum = descType as ZEnumType; EnumTypes.Add(zenum); //WordDictionary wordDictionary = zenum.WordTable; //WordDictionaryList.Add(wordDictionary); } else if (descType is ZClassType) { ZClassType zclass = descType as ZClassType; ClassTypes.Add(zclass); //WordDictionary wordDictionary = zclass.WordTable; //WordDictionaryList.Add(wordDictionary); } else { throw new ZyyRTException(); } }
public bool ContainsWord(string text) { return (EnumerableHelper.AnyOne <ZEnumType>(EnumTypes, (ZEnumType zenum) => zenum.ZName == text) || EnumerableHelper.AnyOne <ZClassType>(ClassTypes, (ZClassType zclass) => zclass.ZName == text) || IWordDictionaryHelper.ArrayContainsWord(text, EnumTypes.ToArray()) || IWordDictionaryHelper.ArrayContainsWord(text, ClassTypes.ToArray())); // this.WordDictionaryList.ContainsWord(text); }
public Subroutine(string name, EnumTypes type, string value, Scope scope) { this.name = name; this.type = type; this.value = value; this.issub = true; this.isfun = false; SymbolScope = scope; }
public Symbol(string name, EnumTypes type, string value, Scope scope, bool isSub, bool isFun) { this.name = name; this.type = type; this.value = value; symbolScope = scope; issub = isSub; isfun = isFun; }
public static Token Read(FArchive reader) { reader.ReadUnsafe(out EExprToken currentToken); if (EnumTypes.TryGetValue(currentToken, out var type)) { var tok = type(); tok.Deserialize(reader); return(tok); } throw new NotImplementedException($"Unknown opcode {currentToken}"); }
private IEdmTypeConfiguration GetStructuralTypeOrNull(Type clrType) { IEdmTypeConfiguration configuration = StructuralTypes.SingleOrDefault(edmType => edmType.ClrType == clrType); if (configuration == null) { Type type = TypeHelper.GetUnderlyingTypeOrSelf(clrType); configuration = EnumTypes.SingleOrDefault(edmType => edmType.ClrType == type); } return(configuration); }
public LinkedListNode <Symbol> FindSymbol(EnumTypes type) { while (currentSymbol.Next != null) { if (currentSymbol.Value.SymbolType == type) { return(currentSymbol); } previousSymbol = currentSymbol; currentSymbol = nextSymbol; nextSymbol = currentSymbol.Next; } return(null); }
public static IValidator Validate(EnumTypes type) { switch(type) { case EnumTypes.Boolean: return new BooleanStrategy(); case EnumTypes.Integer: return new IntegerStrategy(); case EnumTypes.EmailingMethod: return new EmailingMethodStrategy(); case EnumTypes.EmailAddress: return new EmailingAddressStrategy(); case EnumTypes.FilePath: return new FilePathStrategy(); case EnumTypes.String: return new StringStrategy(); default: return new UnknownStrategy(); } }
private static string GenerateSchema(IEnumerable <StepDescriptor> steps) { var stepHeaders = string.Join(Environment.NewLine, steps.Select(s => String.Format(StepHeader, s.Name, !s.Properties.Any() ? "Empty" : s.Name))); var stepTypes = string.Join(Environment.NewLine, steps.Select(s => String.Format(StepTemplate , s.Name , String.IsNullOrEmpty(s.Documentation) ? "" : String.Format(StepAnnotation, s.Documentation) , GetStepElements(s) , GetStepAttributes(s) ))); var enumTypes = string.Join(string.Empty, EnumTypes.Select(t => String.Format(EnumTemplate , t.Name , string.Join(string.Empty, Enum.GetNames(t).Select(o => String.Format(EnumOptionTemplate, o))) ))); var schema = String.Format(PackageSchemaGenerator.Xsd, @"\d+(\.\d+){0,3}", stepHeaders, enumTypes, stepTypes); return(schema); }
public void AddZDescType(ZLType descType) { if (descType is ZLEnumInfo) { ZLEnumInfo zenum = descType as ZLEnumInfo; EnumTypes.Add(zenum); } else if (descType is ZLClassInfo) { ZLClassInfo zclass = descType as ZLClassInfo; ClassTypes.Add(zclass); } else { throw new ZyyRTException(); } }
public static string FormatDataOutput(EnumTypes.DataOutputType[] dataOutputs) { StringBuilder sb = new StringBuilder(); if (dataOutputs != null) { for (int i = 0; i < dataOutputs.Length; i++) { sb.Append(EnumUtils.StringValueOf(dataOutputs[i])); if (i + 1 < dataOutputs.Length) { sb.Append(','); } } } return sb.ToString(); }
/// <summary> /// The ModifyNew form is created for editing /// </summary> /// <param name="actor">The actor that will be edited</param> /// <param name="type">The type of actors that can be returned</param> /// <returns></returns> public static ModifyNew getModifyNew(Actor actor, EnumTypes.actorType type) { var mod = getModifyNew(type); mod.Text = "Edit blueprint"; mod.Cancel.Enabled = false; edit = true; if (actor.boolInstance) { mod.propGrid.SelectedObjects = new object[] { actor.instance }; boolInstance = true; } else { mod.propGrid.SelectedObjects = new object[] { actor.blueprint }; boolInstance = false; } return mod; }
public void Insert(string Title, string Contents, string Ip, EnumTypes types = EnumTypes.其他分类, string TypeName = "", string Others = "", string oldXML = "", string newXML = "") { Logs logs = new Logs(); logs.Id = Guid.NewGuid(); logs.CreatedDate = DateTime.Now; logs.CreatedId = Guid.NewGuid(); logs.CreatedName = "admin"; logs.UpdateId = Guid.NewGuid(); logs.UpdateDate = DateTime.Now; logs.UpdateName = "admin"; logs.Title = Title; logs.TypeName = TypeName; logs.IPAddress = Ip; logs.Contents = Contents; logs.Others = Others; logs.OldXml = string.IsNullOrEmpty(oldXML) ? null : oldXML; logs.NewXml = string.IsNullOrEmpty(newXML) ? null : newXML; _logRepositoty.Insert(logs); }
static void Main(string[] args) { EnumTypes types = EnumTypes.SECOND; switch (types) { case EnumTypes.FIRST: case EnumTypes.SECOND: Console.WriteLine(EnumTypes.FIRST); Console.WriteLine(EnumTypes.SECOND); break; case EnumTypes.THRID: Console.WriteLine(EnumTypes.THRID); break; default: break; } if (types == EnumTypes.FIRST || types == EnumTypes.SECOND) { } else if (types == EnumTypes.SECOND) { } else if (types == EnumTypes.THRID) { } else { } //Console.WriteLine((int)EnumTypes.SECOND); Console.ReadLine(); }
private static Dictionary <string, Dictionary <string, int> > GetEnumTypesFromAssembly() { Dictionary <string, Dictionary <string, Int32> > EnumTypesDic = new Dictionary <string, Dictionary <string, int> >(); //TO DO : GET ASSEMBLY FROM PARAM EnumTypes enumTypesClass = new EnumTypes(); Assembly asbly = Assembly.GetAssembly(enumTypesClass.GetType()); foreach (Type type in asbly.GetTypes()) { if (type.IsEnum) { MemberInfo[] typeInfo = type.GetMembers(); EnumTypesDic.Add(type.Name, new Dictionary <string, Int32>()); foreach (MemberInfo info in typeInfo) { if (info is FieldInfo) { string keyName = info.Name; if (keyName != "value__") { object value = ((FieldInfo)info).GetRawConstantValue(); EnumTypesDic[type.Name].Add(keyName, Convert.ToInt32(value)); } } } } } return(EnumTypesDic); }
private void DefineFunctions() { functions = new List <Tuple <string, EnumTypes, string> >(); currentToken = tokens.First; nextToken = currentToken.Next; previousToken = currentToken.Previous; while (currentToken != null) { if (((EnumKeywordType)currentToken.Value.Type == EnumKeywordType.FUN && (previousToken != null && (EnumKeywordType)previousToken.Value.Type != EnumKeywordType.END))) { string name = nextToken.Value.Value; EnumTypes type = (EnumTypes)currentToken.Next.Next.Next.Value.Type; Tuple <string, EnumTypes, string> fun = new Tuple <string, EnumTypes, string>(name, type, "function"); functions.Add(fun); } currentToken = nextToken; if (nextToken != null) { nextToken = currentToken.Next; previousToken = currentToken.Previous; } } }
/// <summary> /// Returns a linked list with all the actors connected to the story node from a given type /// </summary> /// <param name="type">The type of actors that are to be returned</param> /// <returns>The linked list containing the acotr</returns> private LinkedList<Actor> loadActors(EnumTypes.actorType type) { LinkedList<Actor> actors = new LinkedList<Actor>(); if (giver != null && giver.type == type) { actors.AddLast(giver); } if (villian != null && villian.type == type) { actors.AddLast(villian); } if (extra != null) { foreach (Actor act in extra) { if (act.type == type) { actors.AddLast(act); } } } return actors; }
private void CreateBinaryInstruction(EnumTypes Type, EnumOperator operation, string name, dynamic val) { List<string> ops = new List<string>(0); DefineVariable(Type, name, null); switch(operation) { case EnumOperator.ASSIGNMEMT: { for (int i = 0; i < branches.Count; i++) { ops.Add(this.thetree.ASTbranches.ElementAt(i).name); ops.Add((string)this.thetree.ASTbranches.ElementAt(i).Value); } } break; } }
/// <summary> /// Creates an actor from an instance /// </summary> /// <param name="actor">The instance that the actor is created from</param> /// <param name="type">The type of the instance</param> public Actor(NWN2Toolset.NWN2.Data.Instances.INWN2Instance actor, EnumTypes.actorType type) { instance = actor; this.type = type; boolInstance = true; }
public ItemViewModel(string name, EnumTypes type) { _name = name; _type = type; }
/// <summary> /// Edit a actor in a multiple actor grid /// </summary> /// <param name="grid"></param> /// <param name="type">The type of actor</param> /// <param name="dataName">The name of the datacell</param> /// <param name="list">The list of actors (extra, item, triggers)</param> private static void editActor(DataGridView grid, EnumTypes.actorType type, String dataName, LinkedList<Actor> list) { if (grid.SelectedRows.Count > 0) { int gridNumber = grid.SelectedRows[0].Index; Actor oldActor = gridGetActor(grid, dataName); if (oldActor != null) { modifyForm = ModifyNew.getModifyNew(oldActor, type); if (modifyForm.ShowDialog() == DialogResult.OK) { Actor actor = ModifyNew.lastActor; grid[0, gridNumber].Value = actor.ToString(); grid[1, gridNumber].Value = actor.Tag; grid[dataName, gridNumber].Value = actor; if (list != null) { list.Remove(oldActor); list.AddLast(actor); } } } } }
private void newClick(ref Actor primeActor, DataGridView grid, Button editButton, Button removeButton, EnumTypes.actorType type, String dataCell) { LinkedList<Actor> actors = new LinkedList<Actor>(); insertActor(grid, type, ref actors, dataCell); if (actors.Count > 0) { primeActor = actors.First.Value; } }
private void CreateNumericalInstruction(EnumTypes Type, EnumOperator operation, string name, dynamic val) { List<string> ops = new List<string>(0); DefineVariable(Type, name, null); switch (operation) { case EnumOperator.UNARY_PLUS: { for (int i = 0; i < branches.Count; i++) { if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])")) { ops.Add((string)branches.ElementAt(i).Value); //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])")) //{ // ops.Add((string)this.tree.getroot(tree).Value); //} for (int j = 0; j < this.thetree.ASTbranches.Count; j++) { if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])")) { ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value); } else { continue; } } } else { continue; } if (ops.Count < 1) { try { throw new InvalidOperationException("Cannot Create Specified instruction type with no operands"); } catch (InvalidOperationException ex) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(ex.GetType()); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ResetColor(); } finally { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS "); Console.ResetColor(); System.Threading.Thread.Sleep(2500); Environment.Exit(-1); } } } Instruction ins = new Instruction((int)EnumOpcodes.ADD, ops.ToArray<string>()); break; } case EnumOperator.UNARY_MINUS: { for (int i = 0; i < branches.Count; i++) { if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])")) { ops.Add((string)branches.ElementAt(i).Value); //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])")) //{ // ops.Add((string)this.tree.getroot(tree).Value); //} for (int j = 0; j < this.thetree.ASTbranches.Count; j++) { if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])")) { ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value); } else { continue; } } } else { continue; } if (ops.Count < 1) { try { throw new InvalidOperationException("Cannot Create Specified instruction type with no operands"); } catch (InvalidOperationException ex) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(ex.GetType()); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ResetColor(); } finally { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS "); Console.ResetColor(); System.Threading.Thread.Sleep(2500); Environment.Exit(-1); } } } Instruction ins = new Instruction((int)EnumOpcodes.SUB, ops.ToArray<string>()); break; } case EnumOperator.UNARY_MULTIPLY: { bool issigned = false; for (int i = 0; i < branches.Count; i++) { if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])")) { if ((int)branches.ElementAt(i).Value < 0) { issigned = true; } ops.Add((string)branches.ElementAt(i).Value); //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])")) //{ // ops.Add((string)this.tree.getroot(tree).Value); //} for (int j = 0; j < this.thetree.ASTbranches.Count; j++) { if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])")) { ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value); } else { continue; } } } else { continue; } if (ops.Count < 1) { try { throw new InvalidOperationException("Cannot Create Specified instruction type with no operands"); } catch (InvalidOperationException ex) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(ex.GetType()); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ResetColor(); } finally { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS "); Console.ResetColor(); System.Threading.Thread.Sleep(2500); Environment.Exit(-1); } } } if (issigned) { Instruction ins = new Instruction((int)EnumOpcodes.IMUL, ops.ToArray<string>()); } else { Instruction ins = new Instruction((int)EnumOpcodes.MUL,ops.ToArray<string>()); } break; } case EnumOperator.UNARY_DIVIDE: { bool issigned = false; for (int i = 0; i < branches.Count; i++) { if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])")) { if ((int)branches.ElementAt(i).Value < 0) { issigned = true; } ops.Add((string)branches.ElementAt(i).Value); //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])")) //{ // ops.Add((string)this.tree.getroot(tree).Value); //} for (int j = 0; j < this.thetree.ASTbranches.Count; j++) { if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])")) { ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value); } else { continue; } } } else { continue; } if (ops.Count < 1) { try { throw new InvalidOperationException("Cannot Create Specified instruction type with no operands"); } catch (InvalidOperationException ex) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(ex.GetType()); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ResetColor(); } finally { Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS "); Console.ResetColor(); System.Threading.Thread.Sleep(2500); Environment.Exit(-1); } } } if (issigned) { Instruction ins = new Instruction((int)EnumOpcodes.IDIV, ops.ToArray<string>()); } else { Instruction ins = new Instruction((int)EnumOpcodes.DIV, ops.ToArray<string>()); } break; } } return; }
public EnumValueModel FindEnumValue(string type, string name) { return(EnumTypes .First(enumType => string.Compare(enumType.Type, type, StringComparison.OrdinalIgnoreCase) == 0).Values .First(enumValue => string.Compare(enumValue.Name, name, StringComparison.OrdinalIgnoreCase) == 0)); }
/// <summary> /// Inserts the actors into the choosen grid, as well as adding them to the quests list of /// </summary> /// <param name="grid">The grid where the actors are inserted</param> /// <param name="actors">The list of actors which we are going to insert</param> /// <param name="actorList">The list of actors that the system is going to add the new actors to</param> /// <param name="dataCell">The cell in the grid where the actor object is going to be stored</param> /// <param name="type">The type of the actors</param> private static void setGrid(DataGridView grid, LinkedList<Actor> actors, LinkedList<Actor> actorList, String dataCell, EnumTypes.actorType type) { int i = grid.RowCount; if (actors != null) { foreach (Actor actor in actors) { debug("Got actor"); if ((actor.type & type) == actor.type) { debug("set value in grid"); grid.RowCount++; grid[0, i].Value = actor.ToString(); grid[1, i].Value = actor.Tag; if (actorList != null) actorList.AddLast(actor); grid[dataCell, i].Value = actor; debug("Starting image"); if (type == EnumTypes.actorType.Item) fixImage(actor, grid, i); i++; } } } }
public Function(string name, EnumTypes type, string value, Scope scope) : base(name, type, value, scope) { issub = false; isfun = true; }
/// <summary> /// Creates an actor from a blueprint /// </summary> /// <param name="actor">The blueprint that the actor will contain</param> /// <param name="type">The type of the blueprint</param> public Actor(NWN2Toolset.NWN2.Data.Blueprints.INWN2Blueprint actor, EnumTypes.actorType type) { blueprint = actor; this.type = type; boolInstance = false; }
public ValueExpressionASTNode(EnumTypes nodeDataType, string value, BaseASTNode pNodeData) { this.nodeDataType = nodeDataType; this.value = value; this.PNodeData = pNodeData; }
/// <summary> /// The "gasket" method that is used by all the methods that can have multiple actors /// In other words: extras, items and triggers /// </summary> /// <param name="grid">The grid where the actors must be added</param> /// <param name="editButton">The edit button that must be enabled, if there at the end of the method /// is at least one element in the grid</param> /// <param name="removeButton">Ditto for the remove button</param> /// <param name="type">The type of the actor we are looking for</param> /// <param name="actorList">The list of actors that we are working with</param> /// <param name="dataCell">The name of the cell in the grid that stores the actual blueprint /// of the actors we extract</param> private static void genericBrowseMultiple(DataGridView grid, EnumTypes.actorType type, ref LinkedList<Actor> actorList, String dataCell) { getBlueprint getBlueprintForm = getBlueprint.getBlue(type); if (getBlueprintForm.ShowDialog() == DialogResult.OK) { LinkedList<Actor> actors = getBlueprintForm.getBlueprints(); setGrid(grid, actors, actorList, dataCell, type); } }
private bool isAlphaNumerical(EnumTypes Type) { return (alphanumericaltypes.Contains<int>(Convert.ToInt32(Type))); }
public ReferenceExpressionASTNode(EnumTypes nodeDataType, string identifier, BaseASTNode pNodeData) { this.nodeDataType = nodeDataType; this.identifier = identifier; this.PNodeData = pNodeData; }
private bool IsBinary(EnumTypes Type) { return (!alphanumericaltypes.Contains<int>(Convert.ToInt32(Type)) && !numericaltypes.Contains<int>(Convert.ToInt32(Type))) ? true : false; }
/// <summary> /// Inserts an actor in the grid /// </summary> /// <param name="grid">The grid where the actor will be inserted</param> /// <param name="editButton">The edit button that will be enabled (if there is an actor)</param> /// <param name="removeButton">Ditto for the removeButton</param> /// <param name="type">The type of the new blueprint</param> /// <param name="list">The list that the new actor will be added to</param> /// <param name="dataName">The name of the data cell in the grid</param> private static void insertActor(DataGridView grid, EnumTypes.actorType type, ref LinkedList<Actor> list, String dataCell) { modifyForm = ModifyNew.getModifyNew(type); // If the user wants to create a new blueprint, and there is only one type, then we might as well create that modifyForm.testCreate(); Actor actor = null; if (modifyForm.ShowDialog() == DialogResult.OK) { actor = ModifyNew.lastActor; if (actor != null) { LinkedList<Actor> dummyList = new LinkedList<Actor>(); dummyList.AddLast(actor); setGrid(grid, dummyList, list, dataCell, type); } } }
private bool IsNumerical(EnumTypes Type) { //int[] numericaltypes = { 0, 3, 4, 5, 6, 9, 11 }; return (numericaltypes.Contains<int>(Convert.ToInt32(Type))); }
/// <summary> /// The modifyNew form is created for creating new actors /// </summary> /// <param name="type">The type of actors that can be returned</param> /// <returns></returns> public static ModifyNew getModifyNew(EnumTypes.actorType type) { edit = false; saveValue = false; if (modifyNew == null) { modifyNew = new ModifyNew(); debug("Create new modify"); } modifyNew.Text = "Create new blueprint"; modifyNew.comboType.Items.Clear(); modifyNew.propGrid.SelectedObjects = null; modifyNew.propGrid.RefreshGrid(); // I set which types can created if ((type & EnumTypes.actorType.Creature) == EnumTypes.actorType.Creature) modifyNew.comboType.Items.Add("Creature"); if ((type & EnumTypes.actorType.Door) == EnumTypes.actorType.Door) modifyNew.comboType.Items.Add("Door"); if ((type & EnumTypes.actorType.Placeable) == EnumTypes.actorType.Placeable) modifyNew.comboType.Items.Add("Placeable"); if ((type & EnumTypes.actorType.Item) == EnumTypes.actorType.Item) modifyNew.comboType.Items.Add("Item"); if ((type & EnumTypes.actorType.TriggerRegion) == EnumTypes.actorType.TriggerRegion) modifyNew.comboType.Items.Add("Trigger"); if (modifyNew.comboType.Items.Count > 0) modifyNew.comboType.SelectedIndex = 0; return modifyNew; }
private static dynamic DefineVariable(EnumTypes Type, string name, dynamic val = null) { // System.Type var = val.GetType(); dynamic memory = val; return memory; }
public static string FormatOffer(EnumTypes.OfferType[] offers) { StringBuilder sb = new StringBuilder(); if (offers != null) { for (int i = 0; i < offers.Length; i++) { sb.Append(EnumUtils.StringValueOf(offers[i])); if (i + 1 < offers.Length) { sb.Append(','); } } } return sb.ToString(); }
private void CreateAlphaNumericalInstruction(EnumTypes Type, EnumOperator operation, string name, dynamic val) { DefineVariable(Type, name, null); }
public FunctionDeclarationASTNode(EnumTypes functionReturnType, string functionName, BaseASTNode pNodeData) { this.functionReturnType = functionReturnType; this.functionName = functionName; this.PNodeData = pNodeData; }
public bool ContainsZType(string zname) { return(ZTypeListHelper.Contains(zname, EnumTypes.ToArray()) || ZTypeListHelper.Contains(zname, ClassTypes.ToArray())); }