/// <summary> /// Create a freezable GetVariable step. /// </summary> public static IFreezableStep CreateFreezableGetVariable( VariableName variableName, TextLocation?location) { var dict = new StepParameterDict { { new StepParameterReference.Named(nameof(GetVariable <object> .Variable)), new FreezableStepProperty.Variable(variableName, location) } }; var fpd = new FreezableStepData(dict, location); var step = new CompoundFreezableStep( "GetVariable", fpd, location ); return(step); }
/// <summary> /// Tries to add a variableName with this type to the type resolver. /// </summary> public Result <Unit, IErrorBuilder> TryAddType( VariableName variable, TypeReference typeReference) { var actualType = typeReference.TryGetType(this); if (actualType.IsFailure) { return(actualType.ConvertFailure <Unit>()); } if (MyDictionary.TryGetValue(variable, out var previous)) { if (previous.Equals(typeReference)) { return(Unit.Default); } return(ErrorCode.WrongVariableType.ToErrorBuilder(variable.Name, typeReference.Name)); } MyDictionary.Add(variable, typeReference); return(Unit.Default); }