/* * Create an pre-defined property from a ref VariableDeclaration */ private TES5Property CreatePropertyFromReference(TES4VariableDeclaration declaration, TES5GlobalVariables globalVariables) { string variableName = declaration.VariableName; Nullable <int> tes4FormID = null; ITES5Type type; if (globalVariables.ContainsName(variableName)) { type = TES5BasicType.T_GLOBALVARIABLE; } else { tes4FormID = declaration.FormID; if (declaration.TES5Type != null) { type = declaration.TES5Type; } else { if (declaration.VariableType != TES4Type.T_REF) { throw new ConversionException("Unknown type: " + declaration.VariableType.Name + " " + declaration.VariableType.Name); } ITES5Type?esmType = esmAnalyzer.GetTypeByEDIDWithFollow(variableName, false); //This seems to return null always, which makes sense since declaration.TES5Type is null. type = esmType != null ? esmType : TES5BasicType.T_FORM; } } return(ConstructWithTES4FormID(variableName, type, variableName, tes4FormID)); }
public TES5Property CreateAndAddProperty(TES4VariableDeclaration variable, TES5GlobalScope globalScope, TES5GlobalVariables globalVariables) { TES5Property property = CreateProperty(variable, globalVariables); TES5Property?existingPropertyWithDifferentType = globalScope.Properties.Where(p => p.Name.Equals(property.Name, StringComparison.OrdinalIgnoreCase) && p.TES5DeclaredType != property.TES5DeclaredType).FirstOrDefault(); if (existingPropertyWithDifferentType != null) { throw GetDuplicatePropertyException(existingPropertyWithDifferentType.Name, existingPropertyWithDifferentType.TES5DeclaredType.OriginalName, property.TES5DeclaredType.OriginalName); } globalScope.AddProperty(property); return(property); }
/* * Create an pre-defined property from a ref VariableDeclaration */ private static TES5Property CreatePropertyFromReference(TES4VariableDeclaration declaration, TES5GlobalVariables globalVariables) { string variableName = declaration.VariableName; if (globalVariables.ContainsName(variableName)) { return(new TES5Property(variableName, TES5BasicType.T_GLOBALVARIABLE, variableName)); } else { return(new TES5Property(variableName, TES5BasicType.T_FORM, variableName)); } }
private TES5Property CreateProperty(TES4VariableDeclaration variable, TES5GlobalVariables globalVariables) { string variableName = variable.VariableName; TES4Type variableType = variable.VariableType; if (variableType == TES4Type.T_FLOAT) { return(ConstructWithoutFormID(variableName, TES5BasicType.T_FLOAT, null)); } if (variableType == TES4Type.T_INT || variableType == TES4Type.T_SHORT || variableType == TES4Type.T_LONG) { return(ConstructWithoutFormID(variableName, TES5BasicType.T_INT, null)); } if (variableType == TES4Type.T_REF) { return(CreatePropertyFromReference(variable, globalVariables)); } throw new ConversionException("Unknown variable declaration type."); }