Пример #1
0
        public AnonymousMethodSymbol(CodeMemberSymbol containingMember, ISymbolTable stackContext, TypeSymbol returnType, bool isStatic)
            : base(SymbolType.AnonymousMethod, /* name */ String.Empty, (TypeSymbol)containingMember.Parent, returnType) {
            SetVisibility(isStatic ? MemberVisibility.Public | MemberVisibility.Static : MemberVisibility.Public);
            _containingMember = containingMember;
            _stackContext = stackContext;

            _containingMember.AddAnonymousMethod(this);
        }
Пример #2
0
        public StatementBuilder(ILocalSymbolTable symbolTable, CodeMemberSymbol memberContext, IErrorHandler errorHandler, CompilerOptions options) {
            _symbolTable = symbolTable;
            _memberContext = memberContext;
            _symbolSet = memberContext.SymbolSet;
            _errorHandler = errorHandler;

            _expressionBuilder = new ExpressionBuilder(symbolTable, memberContext, errorHandler, options);
        }
        public AnonymousMethodSymbol(CodeMemberSymbol containingMember, ISymbolTable stackContext, TypeSymbol returnType, bool isStatic)
            : base(SymbolType.AnonymousMethod, /* name */ String.Empty, (TypeSymbol)containingMember.Parent, returnType)
        {
            SetVisibility(isStatic ? MemberVisibility.Public | MemberVisibility.Static : MemberVisibility.Public);
            _containingMember = containingMember;
            _stackContext     = stackContext;

            _containingMember.AddAnonymousMethod(this);
        }
Пример #4
0
 public ExpressionBuilder(ILocalSymbolTable symbolTable, CodeMemberSymbol memberContext, IErrorHandler errorHandler, CompilerOptions options) {
     _symbolTable = symbolTable;
     _symbolContext = memberContext;
     _memberContext = memberContext;
     _classContext = ((ClassSymbol)memberContext.Parent).PrimaryPartialClass;
     _symbolSet = memberContext.SymbolSet;
     _errorHandler = errorHandler;
     _options = options;
 }
Пример #5
0
        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);
                }
            }

            return new SymbolImplementation(statements, _rootScope);
        }