private void HandleFragmentConflict(ISymbolTable context, IProblemPipe problemPipe) { if (ProblemMetadata != null) problemPipe.AddProblem (_problemMetadata); context.MakeUnsafe (_symbol); }
private void HandleFragmentConflict(ISymbolTable context, IProblemPipe problemPipe) { if (ProblemMetadata != null) { problemPipe.AddProblem(_problemMetadata); } context.MakeUnsafe(_symbol); }
public void Analyze(MethodCall methodCall, ISymbolTable context, List <IPreCondition> preConditions) { Method method = IntrospectionUtility.ExtractMethod(methodCall); if (Analyzes(method) && methodCall.Callee is MemberBinding) { MemberBinding memberBinding = (MemberBinding)methodCall.Callee; if (IsFragmentParameterInferenceMethod(method)) { string variableName; if (IntrospectionUtility.IsVariable(memberBinding.TargetObject, out variableName)) { Fragment parameterFragment = ParameterFragmentUtility.ParameterFragmentIntersection(methodCall, context); Fragment targetObjectFragment = context.GetFragmentType(variableName); if (targetObjectFragment == Fragment.CreateLiteral() || targetObjectFragment.Undefined) { context.MakeSafe(variableName, parameterFragment); } else { if (targetObjectFragment == Fragment.CreateEmpty() && parameterFragment != Fragment.CreateLiteral()) // && parameterFragment != Fragment.CreateEmpty() { ProblemMetadata problemMetadata = new ProblemMetadata(methodCall.UniqueKey, methodCall.SourceContext, parameterFragment, targetObjectFragment); IPreCondition precondition = new CustomInferencePreCondition(variableName, parameterFragment, problemMetadata); preConditions.Add(precondition); } else if (!FragmentUtility.FragmentTypesAssignable(parameterFragment, targetObjectFragment)) { context.MakeUnsafe(variableName); } } } } else if (!IsSafeMethod(method)) { string variableName; if (IntrospectionUtility.IsVariable(memberBinding.TargetObject, out variableName)) { context.MakeUnsafe(variableName); } } } }
public void Clone_ReturnsDeepCopy_True() { _symbolTable.MakeSafe("key", Fragment.CreateNamed("FragmentType")); ISymbolTable clone = _symbolTable.Copy(); clone.MakeUnsafe("key"); ISymbolTable result = _symbolTable.Copy(); Assert.That(result.IsAssignableTo("key", Fragment.CreateNamed("FragmentType")), Is.True); }
private void PassReturnFragmentTypeToContext(Expression operand, Parameter parameter) { string symbol = IntrospectionUtility.GetVariableName(operand); Fragment fragmentType = FragmentUtility.GetFragmentType(parameter.Attributes); if (FragmentUtility.ContainsFragment(parameter.Attributes)) { _symbolTable.MakeSafe(symbol, fragmentType); } else { _symbolTable.MakeUnsafe(symbol); } }
private void CheckAssignment(AssignmentStatement assignmentStatement, string targetName, HandleContext context) { ISymbolTable symbolTable = context.SymbolTable; Fragment targetFragmentType = symbolTable.GetFragmentType(targetName); Fragment sourceFragmentType = symbolTable.InferFragmentType(assignmentStatement.Source); if (targetFragmentType != sourceFragmentType) { symbolTable.MakeUnsafe(targetName); } else { SetPreConditionForIndexerObject(assignmentStatement, targetName, sourceFragmentType, context); } }
private void SetSymbolFragmentType(string name, AttributeNodeCollection attributes) { if (!_result.Contains(name)) { if (FragmentUtility.ContainsFragment(attributes)) { Fragment fragmentType = FragmentUtility.GetFragmentType(attributes); _result.MakeSafe(name, fragmentType); } else { _result.MakeUnsafe(name); } } }
private void InferArrayFragment(AssignmentStatement assignmentStatement, string targetName, HandleContext context) { ISymbolTable symbolTable = context.SymbolTable; Fragment targetFragmentType = symbolTable.InferFragmentType(assignmentStatement.Source); if (context.ArrayFragmentTypeDefined[targetName] == false) { symbolTable.MakeSafe(targetName, targetFragmentType); context.ArrayFragmentTypeDefined[targetName] = true; } else if (symbolTable.GetFragmentType(targetName) == Fragment.CreateLiteral()) { symbolTable.MakeSafe(targetName, targetFragmentType); } else if (symbolTable.GetFragmentType(targetName) != targetFragmentType && targetFragmentType != Fragment.CreateLiteral()) { symbolTable.MakeUnsafe(targetName); } }
public void Analyze(MethodCall methodCall, ISymbolTable context, List<IPreCondition> preConditions) { Method method = IntrospectionUtility.ExtractMethod (methodCall); if (Analyzes(method) && methodCall.Callee is MemberBinding) { MemberBinding memberBinding = (MemberBinding) methodCall.Callee; if (IsFragmentParameterInferenceMethod (method)) { string variableName; if (IntrospectionUtility.IsVariable (memberBinding.TargetObject, out variableName)) { Fragment parameterFragment = ParameterFragmentUtility.ParameterFragmentIntersection (methodCall, context); Fragment targetObjectFragment = context.GetFragmentType (variableName); if (targetObjectFragment == Fragment.CreateLiteral() || targetObjectFragment.Undefined) { context.MakeSafe (variableName, parameterFragment); } else { if (targetObjectFragment == Fragment.CreateEmpty() && parameterFragment != Fragment.CreateLiteral()) // && parameterFragment != Fragment.CreateEmpty() { ProblemMetadata problemMetadata = new ProblemMetadata(methodCall.UniqueKey, methodCall.SourceContext, parameterFragment, targetObjectFragment); IPreCondition precondition = new CustomInferencePreCondition(variableName, parameterFragment, problemMetadata); preConditions.Add(precondition); } else if (!FragmentUtility.FragmentTypesAssignable(parameterFragment, targetObjectFragment)) { context.MakeUnsafe(variableName); } } } } else if (!IsSafeMethod(method)) { string variableName; if (IntrospectionUtility.IsVariable(memberBinding.TargetObject, out variableName)) { context.MakeUnsafe(variableName); } } } }