static void AddDefaultConstructors() //Adds empty constructors to every class, if they aren't present { foreach (ClassDeclarationNode classDeclaration in _rootNode.ClassDeclarations) { bool emptyConstructor = false; foreach (ConstructorDeclarationNode contructor in classDeclaration.ConstructorDeclarations) { if (contructor.ParameterNames.Count == 0) { emptyConstructor = true; break; } } if (!emptyConstructor) { //classDeclaration.AddConstructorDeclaraton(new ConstructorDeclarationNode()); ConstructorDeclarationNode constructor = new ConstructorDeclarationNode(); foreach (VariableDeclarationNode variable in classDeclaration.VariableDeclarations) { } } } }
private SymbolImplementation BuildImplementation(ISymbolTable symbolTable, CodeMemberSymbol symbolContext, BlockStatementNode implementationNode, bool addAllParameters) { rootScope = new SymbolScope(symbolTable); currentScope = rootScope; List <Statement> statements = new List <Statement>(); StatementBuilder statementBuilder = new StatementBuilder(this, symbolContext, errorHandler, options); if (symbolContext.Parameters != null) { int parameterCount = symbolContext.Parameters.Count; if (addAllParameters == false) { // For property getters (including indexers), we don't add the last parameter, // which happens to be the "value" parameter, which only makes sense // for the setter. parameterCount--; } for (int paramIndex = 0; paramIndex < parameterCount; paramIndex++) { currentScope.AddSymbol(symbolContext.Parameters[paramIndex]); } } if (symbolContext.Type == SymbolType.Constructor && (((ConstructorSymbol)symbolContext).Visibility & MemberVisibility.Static) == 0) { Debug.Assert(symbolContext.Parent is ClassSymbol); if (((ClassSymbol)symbolContext.Parent).BaseClass != null) { BaseInitializerExpression baseExpr = new BaseInitializerExpression(); ConstructorDeclarationNode ctorNode = (ConstructorDeclarationNode)symbolContext.ParseContext; if (ctorNode.BaseArguments != null) { ExpressionBuilder expressionBuilder = new ExpressionBuilder(this, symbolContext, errorHandler, options); Debug.Assert(ctorNode.BaseArguments is ExpressionListNode); ICollection <Expression> args = expressionBuilder.BuildExpressionList((ExpressionListNode)ctorNode.BaseArguments); foreach (Expression paramExpr in args) { baseExpr.AddParameterValue(paramExpr); } } statements.Add(new ExpressionStatement(baseExpr)); } } foreach (StatementNode statementNode in implementationNode.Statements) { Statement statement = statementBuilder.BuildStatement(statementNode); if (statement != null) { statements.Add(statement); } } string thisIdentifier = "this"; if (symbolContext.Type == SymbolType.AnonymousMethod) { thisIdentifier = "$this"; } return(new SymbolImplementation(statements, rootScope, thisIdentifier)); }
/// <inheritdoc/> public override void VisitConstructorDeclarationNode(ConstructorDeclarationNode node) { // Types cannot be declared in a constructor, so we stop here }
public void enterConstructor(ConstructorDeclarationNode declaration) { methodInfos.add(declaration.getUserData(typeof(MethodInfo))); }
// Types cannot be declared in a constructor, so we stop here public override void VisitConstructorDeclarationNode(ConstructorDeclarationNode node) { }