public SymbolImplementation BuildMethod(SourceMethodDefinitionSymbol methodSymbol) { var methodBody = methodSymbol.Syntax.Body; var symbolTable = (ISymbolTable) methodSymbol.Parent; _rootScope = new SymbolScope(symbolTable); _currentScope = _rootScope; var symbolContext = methodSymbol; var implementationNode = methodBody; var statements = new List<BoundStatement>(); var statementBuilder = new StatementBinder(this, symbolContext, _diagnostics); if (symbolContext.Parameters != null) { int parameterCount = symbolContext.Parameters.Length; for (int paramIndex = 0; paramIndex < parameterCount; paramIndex++) _currentScope.AddSymbol(symbolContext.Parameters[paramIndex]); } foreach (var statementNode in implementationNode.Statements) { var statement = statementBuilder.BuildStatement(statementNode); if (statement != null) statements.Add(statement); } return new SymbolImplementation(statements.ToImmutableArray(), _rootScope); }
public SymbolImplementation(ImmutableArray<BoundStatement> statements, SymbolScope scope) { Scope = scope; Statements = statements; DeclaresVariables = statements.Any(x => x is BoundVariableDeclaration); }
public BoundExpression BuildField(SourceFieldSymbol fieldSymbol) { _rootScope = new SymbolScope((ISymbolTable)fieldSymbol.Parent); _currentScope = _rootScope; BoundExpression initializerExpression = null; var fieldDeclarationNode = fieldSymbol.Syntax; Debug.Assert(fieldDeclarationNode != null); //var initializerNode = fieldDeclarationNode.Initializer; //if (initializerNode.Value != null) //{ // var expressionBuilder = new ExpressionBinder(this, fieldSymbol, _diagnostics); // initializerExpression = expressionBuilder.BindExpression(initializerNode.Value); // if (initializerExpression is BoundMemberExpression) // initializerExpression = expressionBuilder.TransformMemberExpression((MemberExpression) initializerExpression); //} throw new NotImplementedException(); // TODO: Cache result. return initializerExpression; }
public void AddChildScope(SymbolScope scope) { if (_childScopes == null) { _childScopes = new List <SymbolScope>(); } _childScopes.Add(scope); }
public void AddChildScope(SymbolScope scope) { if (_childScopes == null) _childScopes = new List<SymbolScope>(); _childScopes.Add(scope); }
public SymbolScope(SymbolScope parentScope) : this((ISymbolTable)parentScope) { Parent = parentScope; }
void ILocalSymbolTable.PushScope() { Debug.Assert(_currentScope != null); var parentScope = _currentScope; _currentScope = new SymbolScope(parentScope); parentScope.AddChildScope(_currentScope); }
void ILocalSymbolTable.PopScope() { Debug.Assert(_currentScope != null); _currentScope = _currentScope.Parent; }