public TotemAst(Statement body, bool isModule, bool printExpressions) { ContractUtils.RequiresNotNull(body, "body"); _body = body; _printExpressions = printExpressions; }
public IfElseStatement(Tuple<Expression, Statement>/*!*/[]/*!*/ testPairs, Statement ifFalse) { ContractUtils.RequiresNotEmpty(testPairs, "testPairs"); ContractUtils.RequiresNotNullItems(testPairs, "testPairs"); _testPairs = testPairs; _ifFalse = ifFalse; }
public TotemAst(Statement body, bool isModule, bool printExpressions, CompilerContext context, int[] lineLocations) : this(isModule, printExpressions, context) { ContractUtils.RequiresNotNull(body, "body"); _body = body; _lineLocations = lineLocations; }
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; }
public SuiteStatement(Statement[]/*!*/ statements) { Assert.NotNull(statements); _statements = statements; }
public LambdaExpression(Parameter[] parameters, Statement body) { _function = new FunctionDefinition(null, parameters, body); }
public RewrittenBodyStatement(Statement originalBody, MSAst.Expression body) { _body = body; _originalBody = originalBody; SetLoc(originalBody.GlobalParent, originalBody.IndexSpan); }
/// <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; }