public void Visit(Statement expression) { if (expression != null) { expression.Accept(this); } }
public void Interprete(Function func, params object[] args) { int j = 0; if (func.ThisVariable != null) { DeclareArgument(func.ThisVariable, args[0]); j = 1; } for (int i = 0; i < func.InputVariables.Count; i++) { DeclareArgument(func.InputVariables[i], args[j]); j++; } func.Body.Accept(this); while (_execLeaf != null) { Statement next = _execLeaf.Successor; if (next != null) { next.Accept(this); } else { break; } } }
public static Statement Forify(this Statement stmt) { Forifier forifier = new Forifier(); stmt.Accept(forifier); return(forifier.Result); }
public override void Visit(GroupClause expression) { Dictionary<object, NLinqGroup> groups = new Dictionary<object, NLinqGroup>(); for(int i=0; i<tuples.Count; i++) { currentTuple = tuples[i]; expression.Expression.Accept(this); object key = result; if (!groups.ContainsKey(key)) { groups.Add(key, new NLinqGroup(key)); } Statement s = new Statement(new Expression[] { expression.Identifier }); s.Accept(this); groups[key].Group.Add(result); } tuples.Clear(); foreach (NLinqGroup g in groups.Values) { List<object> row = new List<object>(); row.Add(g); tuples.Add(row); } }
/// <summary> /// Extracts all atomic statements inside a given statement. /// </summary> /// <param name="stmt"></param> /// <returns>The list of atomic statements, the first entry being the entry.</returns> public static List <Statement> GetAtomicStatements(this Statement stmt) { AtomicStatementExtractor ase = new AtomicStatementExtractor(); stmt.Accept(ase); return(ase.Result); }
/// <summary> /// Determines whether a given statement is empty, that is if it does not perform any operation. /// </summary> /// <param name="stmt">>A statement</param> /// <returns>true if the statement is empty, false if not</returns> public static bool IsEmpty(this Statement stmt) { EmptyStatementDetector esd = new EmptyStatementDetector(); stmt.Accept(esd); return(esd.IsEmpty); }
/// <summary> /// Extracts the first innermost atomic statement inside a given statement. /// </summary> /// <param name="stmt"></param> /// <returns></returns> public static Statement GetInnermostAtomicStatement(this Statement stmt) { InnermostAtomicStatementExtractor ase = new InnermostAtomicStatementExtractor(); stmt.Accept(ase); return(ase.Result); }
public static Statement AsSingleStatement(this Statement stmt) { SingleStatementGetter ssg = new SingleStatementGetter(); stmt.Accept(ssg); return(ssg.Result); }
public static IList <Statement> AsStatementList(this Statement stmt) { StatementListGetter slg = new StatementListGetter(); stmt.Accept(slg); return(slg.Result); }
public static bool NeedsLoopScope(this Statement stmt, LoopBlock loop) { LoopControlDetector lcd = new LoopControlDetector(loop); stmt.Accept(lcd); return(lcd.Result); }
/// <summary> /// Tries to interpret the statement as "while" loop. /// </summary> /// <param name="stmt">assumed "while" loop</param> /// <returns>an explicit SysDOM representation of the "while" loop, or <c>null</c> if the statement /// does not match the expected pattern</returns> public static LoopBlock AsWhileLoop(this Statement stmt) { WhileLoopRecognizer wlr = new WhileLoopRecognizer(); stmt.Accept(wlr); return(wlr.Result); }
public void Xlat(Statement stmt) { if (stmt != null) { stmt.Accept(this); } }
/// <summary> /// Returns <c>true</c> if the given statement modifies the given variable. /// </summary> /// <remarks> /// The current implementation is not capable of detecting modifications of variables which are referenced as "out" arguments of some method. /// </remarks> /// <param name="stmt">statement</param> /// <param name="variable">variable</param> public static bool Modifies(this Statement stmt, IStorable variable) { VariableModificationDetector vmd = new VariableModificationDetector(variable); stmt.Accept(vmd); return(vmd.Result); }
/// <summary> /// Returns the set of direct successors of a statement. /// </summary> /// <remarks> /// This operation is only valid on atomic statements, that is all statement types except <c>CompoundStatement</c> and /// <c>LoopBlock</c>. /// Furthermore, only atomic statements constitute the result enumeration. /// </remarks> /// <param name="stmt">statement whose program flow successors shall be retrieved</param> /// <returns>an enumeration of all possible program flow successors</returns> public static IEnumerable <Statement> GetProgramflowSucessors(Statement stmt) { ProgramflowSuccessorsGetter psg = new ProgramflowSuccessorsGetter(); stmt.Accept(psg); return(psg.Result); }
public static void RemoveAll(this Statement stmt, Statement toRemove) { StatementRemover sr = new StatementRemover() { Match = toRemove }; stmt.Accept(sr); }
/// <summary> /// Tries to interpret the statement as "for" loop. /// </summary> /// <param name="stmt">assumed "for" loop</param> /// <param name="level">pattern matching restrictions</param> /// <returns>an explicit SysDOM representation of the "for" loop, or <c>null</c> if the statement /// does not match the expected pattern</returns> public static LoopBlock AsForLoop(this Statement stmt, EForLoopLevel level) { ForLoopRecognizer flr = new ForLoopRecognizer() { Level = level }; stmt.Accept(flr); return(flr.Result); }
/// <summary> /// Determines whether a given statement is an ancestor of some other statement. /// </summary> /// <param name="stmt">An assumed ancestor</param> /// <param name="grandChild">Its assumed granchild</param> /// <returns><c>true</c> if <paramref name="stmt"/> is an ancestor of <paramref name="grandChild"/></returns> /// <remarks>A statement a is an ancestor of a statement b iff there exists a sequence /// s1, s2,... , sN of zero or more statements such that a contains s1, s1 contains s2, /// ... and sN contains b. Furthermore, each statement is per definition an ancestor /// of itself. /// </remarks> public static bool IsAncestor(this Statement stmt, Statement grandChild) { HierarchyAnalyzer ha = new HierarchyAnalyzer() { Grandchild = grandChild }; stmt.Accept(ha); return(ha.IsAncestor); }
public T42Program Generate(Statement stmt) { var globalEnvironment = new FunctionGeneratorEnvironment(); Program.Emit(T42Instruction.DECL(1)); Program.Emit(T42Instruction.BSR("main")); Program.Emit(T42Instruction.END); stmt.Accept(this, globalEnvironment); Program.Link(); return(Program); }
public TResult Visit(Statement statement, TEnvironment environment) { statement.Accept(this, environment); return(default(TResult)); }
public virtual JsInstance Execute(IJintVisitor visitor, JsDictionaryObject that, JsInstance[] parameters) { Statement.Accept((IStatementVisitor)visitor); return(that); }
public void Execute(Statement statement) { Reset(); statement.Accept(this); }
public void Visit(Statement expression) { if (expression != null) expression.Accept(this); }
protected override void DeclareAlgorithm() { _root.Accept(this); }
private ByteCodeChunk VisitStatement(Statement statement) => statement.Accept(this);
/// <summary> /// Returns the set of direct successors of a statement. /// </summary> /// <remarks> /// This operation is only valid on atomic statements, that is all statement types except <c>CompoundStatement</c> and /// <c>LoopBlock</c>. /// Furthermore, only atomic statements constitute the result enumeration. /// </remarks> /// <param name="stmt">statement whose program flow successors shall be retrieved</param> /// <returns>an enumeration of all possible program flow successors</returns> public static IEnumerable<Statement> GetProgramflowSucessors(Statement stmt) { ProgramflowSuccessorsGetter psg = new ProgramflowSuccessorsGetter(); stmt.Accept(psg); return psg.Result; }
public void AcceptLoopBlock(LoopBlock stmt) { IfStatement cond = stmt.Body.AsSingleStatement() as IfStatement; if (cond == null) { return; } if (cond.Conditions.Count != 1 || cond.Branches.Count != 2) { return; } IList <Statement> trueBranch = cond.Branches[0].AsStatementList(); if (trueBranch.Count == 0 || !trueBranch.Last().Equals(new ContinueLoopStatement() { Loop = stmt })) { return; } IList <Statement> falseBranch = cond.Branches[1].AsStatementList(); if (falseBranch.Count == 0) { return; } #if false BreakLoopStatement breaker = new BreakLoopStatement() { Loop = stmt }; Statement trailer = cond.Branches[1].Clone; trailer.RemoveAll(breaker); #endif Statement trailer = cond.Branches[1].Clone; BreakLoopReplacer blr = new BreakLoopReplacer(stmt); trailer.Accept(blr); if (trailer.NeedsLoopScope(stmt)) { return; } #if false CompoundStatement trailer = new CompoundStatement(); trailer.Statements.AddRange(falseBranch.Take(falseBranch.Count - 1)); if (trailer.NeedsLoopScope(stmt)) { return; } BreakLoopStatement breaker = falseBranch.Last() as BreakLoopStatement; if (breaker == null) { return; } if (breaker.Loop.IsAncestor(stmt)) { /* Consider the following situation: * * L1: loop * some outer loop work * L2: loop * if someCondition then * do something * continue L2 * else * do something different * break L1 * end if * end loop L2 * end loop L1 * * As the inner break statement breaks the outer loop, this loop * must be transformed into the following code: * * L1: loop * some outer loop work * while someCondition loop * do something * end while * do something different * break L1 * end loop * */ if (breaker.Loop != stmt) { trailer.Statements.Add(breaker); } } else { return; } #endif CompoundStatement newBody = new CompoundStatement(); newBody.Statements.AddRange(trueBranch.Take(trueBranch.Count - 1)); LoopBlock whileBlock = (LoopBlock)stmt.Clone; whileBlock.HeadCondition = cond.Conditions[0]; whileBlock.Body = newBody; whileBlock.Trailer = trailer; Result = whileBlock; }
/// <summary> /// Execute a statement /// </summary> /// <param name="statement">Statement to execute</param> public void Execute(Statement statement) { statement.Accept(this); }
public static void PreprocessForLoopKindRecognition(this Statement stmt) { Preprocessor prep = new Preprocessor(); stmt.Accept(prep); }
private void Execute(Statement statement) { statement.Accept(this); }
public VoidValueType Visit(Statement statement, ITypeEnvironment environment) { statement.Accept(this, environment); return(new VoidValueType()); }
private void Resolve(Statement statement) { statement?.Accept(this); }
public void VisitStatement(Statement statement) { // 遍历语句内容。 statement.Accept(this); ReturnValue = null; }
public Widget Visit(Statement statement, GuiEnvironment environment) { return(statement.Accept(this, environment)); }
public void Xlat(Statement stmt) { if (stmt != null) { stmt.Accept(this); } }
public string Print(Statement statement) { return(statement.Accept(this)); }