ZoneCodeGenerator: Make static operands able to have the value of an enum entry

This commit is contained in:
Jan
2019-11-21 01:29:24 +01:00
parent 31b279c1e6
commit 5f0f73838f
3 changed files with 22 additions and 2 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ZoneCodeGenerator.Domain;
using ZoneCodeGenerator.Domain.Evaluation;
using ZoneCodeGenerator.Domain.Information;
using ZoneCodeGenerator.Parsing.Matching;
@ -94,6 +95,18 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
}
var nameParts = typenameString.Split(new[] { "::" }, StringSplitOptions.None);
if (nameParts.Length == 1 && arrayIndexStrings.Count == 0)
{
var enumMember = state.Repository.GetAllEnums().SelectMany(_enum => _enum.Members)
.FirstOrDefault(member => member.Name.Equals(nameParts[0]));
if(enumMember != null)
{
return new OperandStatic(enumMember);
}
}
List<MemberInformation> referencedMemberChain = null;
var referencedType = GetUsedTypes(state)