private void CheckByRefArguments(IEnumerable <AstNode> arguments) { foreach (var a in arguments) { var actual = (a is NamedArgumentExpression ? ((NamedArgumentExpression)a).Expression : a); if (actual is DirectionExpression) { var resolveResult = _resolver.Resolve(((DirectionExpression)actual).Expression); if (resolveResult is LocalResolveResult) { var v = ((LocalResolveResult)resolveResult).Variable; var current = _result[v]; if (!current.UseByRefSemantics) { _result[v] = new VariableData(current.Name, current.DeclaringMethod, true); } } } } }
private IVariable CreateTemporaryVariable(IType type, DomRegion region) { string name = _namer.GetVariableName(null, _usedVariableNames); IVariable variable = new SimpleVariable(type, "temporary", region); _variables[variable] = new VariableData(name, null, false); _usedVariableNames.Add(name); return variable; }
private void CheckByRefArguments(IEnumerable<AstNode> arguments) { foreach (var a in arguments) { var actual = (a is NamedArgumentExpression ? ((NamedArgumentExpression)a).Expression : a); if (actual is DirectionExpression) { var resolveResult = _resolver.Resolve(((DirectionExpression)actual).Expression); if (resolveResult is LocalResolveResult) { var v = ((LocalResolveResult)resolveResult).Variable; var current = _result[v]; if (!current.UseByRefSemantics) _result[v] = new VariableData(current.Name, current.DeclaringMethod, true); } } } }
private static ExpressionCompileResult Compile(ResolveResult rr, ITypeDefinition currentType, IMethod currentMethod, ICompilation compilation, IMetadataImporter metadataImporter, INamer namer, IRuntimeLibrary runtimeLibrary, IErrorReporter errorReporter, bool returnValueIsImportant, Dictionary<IVariable, VariableData> variables, ISet<string> usedVariableNames) { variables = variables ?? new Dictionary<IVariable, VariableData>(); usedVariableNames = usedVariableNames ?? new HashSet<string>(); return new ExpressionCompiler(compilation, metadataImporter, namer, runtimeLibrary, errorReporter, variables, new Dictionary<LambdaResolveResult, NestedFunctionData>(), t => { string name = namer.GetVariableName(null, usedVariableNames); IVariable variable = new SimpleVariable(t, "temporary", DomRegion.Empty); variables[variable] = new VariableData(name, null, false); usedVariableNames.Add(name); return variable; }, _ => { throw new Exception("Cannot compile nested functions here"); }, null, new NestedFunctionContext(EmptyList<IVariable>.Instance), null, currentMethod, currentType ).Compile(rr, returnValueIsImportant); }