Exemplo n.º 1
0
        public TotemAst(Statement body, bool isModule, bool printExpressions)
        {
            ContractUtils.RequiresNotNull(body, "body");

            _body = body;
            _printExpressions = printExpressions;
        }
Exemplo n.º 2
0
        public IfElseStatement(Tuple<Expression, Statement>/*!*/[]/*!*/ testPairs, Statement ifFalse)
        {
            ContractUtils.RequiresNotEmpty(testPairs, "testPairs");
            ContractUtils.RequiresNotNullItems(testPairs, "testPairs");

            _testPairs = testPairs;
            _ifFalse = ifFalse;
        }
Exemplo n.º 3
0
        public TotemAst(Statement body, bool isModule, bool printExpressions, CompilerContext context, int[] lineLocations)
            : this(isModule, printExpressions, context)
        {
            ContractUtils.RequiresNotNull(body, "body");

            _body = body;

            _lineLocations = lineLocations;
        }
Exemplo n.º 4
0
        public TotemAst FinishParsing(Statement ret)
        {
            var res = _globalParent;
            _globalParent = null;
            var lineLocs = _tokenizer.GetLineLocations();
            // update line mapping
            if (_sourceUnit.HasLineMapping)
            {
                List<int> newLineMapping = new List<int>();
                int last = 0;
                for (int i = 0; i < lineLocs.Length; i++)
                {
                    while (newLineMapping.Count < i)
                        newLineMapping.Add(last);

                    last = lineLocs[i] + 1;
                    newLineMapping.Add(lineLocs[i]);
                }

                lineLocs = newLineMapping.ToArray();
            }
            res.ParsingFinished(lineLocs, ret);

            return res;
        }
Exemplo n.º 5
0
 public SuiteStatement(Statement[]/*!*/ statements)
 {
     Assert.NotNull(statements);
     _statements = statements;
 }
Exemplo n.º 6
0
 public LambdaExpression(Parameter[] parameters, Statement body)
 {
     _function = new FunctionDefinition(null, parameters, body);
 }
Exemplo n.º 7
0
 public RewrittenBodyStatement(Statement originalBody, MSAst.Expression body)
 {
     _body = body;
     _originalBody = originalBody;
     SetLoc(originalBody.GlobalParent, originalBody.IndexSpan);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Called when parsing is complete, the body is built, the line mapping and language features are known.
        /// 
        /// This is used in conjunction with the constructor which does not take a body.  It enables creating
        /// the outer most PythonAst first so that nodes can always have a global parent.  This lets an un-bound
        /// tree to still provide it's line information immediately after parsing.  When we set the location
        /// of each node during construction we also set the global parent.  When we name bind the global 
        /// parent gets replaced with the real parent ScopeStatement.
        /// </summary>
        /// <param name="lineLocations">a mapping of where each line begins</param>
        /// <param name="body">The body of code</param>
        /// <param name="languageFeatures">The language features which were set during parsing.</param>
        public void ParsingFinished(int[] lineLocations, Statement body)
        {
            ContractUtils.RequiresNotNull(body, "body");

            if (_body != null)
            {
                throw new InvalidOperationException("cannot set body twice");
            }

            _body = body;
            _lineLocations = lineLocations;
        }