Skip to content
Snippets Groups Projects
Select Git revision
  • 2f6e3b2d7125932a983296f5a6343ceb9640e70a
  • master default protected
  • tut_ring_allen
  • docs_furo
  • docs_reorder_cable_cell
  • docs_graphviz
  • docs_rtd_dev
  • ebrains_mirror
  • doc_recat
  • docs_spike_source
  • docs_sim_sample_clar
  • docs_pip_warn
  • github_template_updates
  • docs_fix_link
  • cv_default_and_doc_clarification
  • docs_add_numpy_req
  • readme_zenodo_05
  • install_python_fix
  • install_require_numpy
  • typofix_propetries
  • docs_recipe_lookup
  • v0.10.0
  • v0.10.1
  • v0.10.0-rc5
  • v0.10.0-rc4
  • v0.10.0-rc3
  • v0.10.0-rc2
  • v0.10.0-rc
  • v0.9.0
  • v0.9.0-rc
  • v0.8.1
  • v0.8
  • v0.8-rc
  • v0.7
  • v0.6
  • v0.5.2
  • v0.5.1
  • v0.5
  • v0.4
  • v0.3
  • v0.2.2
41 results

test_morph_expr.cpp

Blame
  • astmanip.hpp 1.21 KiB
    #pragma once
    
    // Helper utilities for manipulating/modifying AST.
    
    #include <string>
    
    #include "expression.hpp"
    #include "location.hpp"
    #include "scope.hpp"
    
    // Create new local variable symbol and local declaration expression in current scope.
    // Returns the local declaration expression.
    
    struct local_declaration {
        expression_ptr local_decl;
        expression_ptr id;
        scope_ptr scope;
    };
    
    local_declaration make_unique_local_decl(
        scope_ptr scope,
        Location loc,
        std::string const& prefix="ll");
    
    // Create a local declaration as for `make_unique_local_decl`, together with an
    // assignment to it from the given expression, using the location of that expression.
    // Returns local declaration expression, assignment expression, new identifier id and
    // consequent scope.
    
    struct local_assignment {
        expression_ptr local_decl;
        expression_ptr assignment;
        expression_ptr id;
        scope_ptr scope;
    };
    
    local_assignment make_unique_local_assign(
        scope_ptr scope,
        Expression* e,
        std::string const& prefix="ll");
    
    inline local_assignment make_unique_local_assign(
        scope_ptr scope,
        expression_ptr& e,
        std::string const& prefix="ll")
    {
        return make_unique_local_assign(scope, e.get(), prefix);
    }