BeginSimp.cxx File Reference

#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <dirent.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <libsherpa/UExcept.hxx>
#include "AST.hxx"
#include "inter-pass.hxx"

Go to the source code of this file.

Functions

static shared_ptr< ASTbeginSimp (shared_ptr< AST > ast, std::ostream &errStream, bool &errFree)
 Remove redundant BEGIN expressions.


Function Documentation

static shared_ptr<AST> beginSimp ( shared_ptr< AST ast,
std::ostream &  errStream,
bool &  errFree 
) [static]

Remove redundant BEGIN expressions.

This simplification pass was originally intended to locate all cases where a BEGIN wraps a single expression and replaces this with the single expression. The transform has no semantic effect, but improves the readability of dumped ASTs. This is okay even in the block syntax, because in any context where the block is mandatory it will be re-inserted by layout.

Later, functionality was added by which local DEFINE forms are converted to the corresponding LET and LETREC forms. After this pass, the only remaining occurrences of DEFINE and RECDEF appear at top level. The implementations of most later passes, notably the resolver and symbol checker, rely on this.

All of the syntactic constructs that wrap implicit BEGIN blocks are converted by the parser to wrap a single expression with an inserted BEGIN block that is marked as compiler inserted. In consequence, the transforms performed here apply to those constructs as well.

This pass may now be misnamed, but all of the simplifications that it performs are vaguely related to begin blocks.

Definition at line 83 of file BeginSimp.cxx.

References at_begin, at_define, at_let, at_letbinding, at_letbindings, at_letrec, at_recdef, at_usesel, ID_IS_GLOBAL, LB_REC_BIND, and AST::make().


Generated on Sat Feb 4 23:59:29 2012 for BitC Compiler by  doxygen 1.4.7