private void Visit(VariableExpr variableExpr) { Symbol symbol = Symbols.Lookup(variableExpr.Identifier); if (symbol != null) { variableExpr.VariableSymbol = symbol; var currentFunction = FunctionStack.Peek(); if (!currentFunction.Locals.Contains(symbol) && !currentFunction.Parameters.Contains(symbol) && !currentFunction.FreeVariables.Contains(symbol)) { FunctionStack.Peek().FreeVariables.Add(symbol); } TypeStack.Push(symbol.Type); variableExpr.Type = symbol.Type; } else { AddError(string.Format("Undeclared variable '{0}'", variableExpr.Identifier), variableExpr); TypeStack.Push(TypeInfo.BasicVoid); } }