Пример #1
0
        public override IAstNode VisitTopLevelExpression([NotNull] TopLevelExpressionContext context)
        {
            BeginFunctionDefinition( );
            var sig    = new Prototype(context.GetSourceSpan( ), RuntimeState.GenerateAnonymousName( ), true);
            var body   = ( IExpression )context.expression( ).Accept(this);
            var retVal = new FunctionDefinition(context.GetSourceSpan( ), sig, body, true);

            RuntimeState.FunctionDefinitions.AddOrReplaceItem(retVal);
            return(retVal);
        }
Пример #2
0
        public override IAstNode VisitTopLevelExpression(TopLevelExpressionContext context)
        {
            BeginFunctionDefinition( );
            var sig    = new Prototype(context.GetSourceSpan( ), RuntimeState.GenerateAnonymousName( ), true);
            var body   = ( IExpression )context.expression( ).Accept(this);
            var retVal = new FunctionDefinition(context.GetSourceSpan( ), sig, body, true);

            // only add valid definitions to the runtime state.
            var errors = retVal.CollectErrors( );

            if (errors.Count == 0)
            {
                RuntimeState.FunctionDefinitions.AddOrReplaceItem(retVal);
            }
            return(retVal);
        }