Changeset 9d7b3ea for src/SynTree


Ignore:
Timestamp:
Mar 3, 2016, 1:28:51 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
36ebd03
Parents:
dbd8652
Message:

First draft of layout function builders

Location:
src/SynTree
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Constant.cc

    rdbd8652 r9d7b3ea  
    1616#include <iostream>
    1717#include <list>
     18#include <string>
    1819
    1920#include "Constant.h"
     
    2829
    2930Constant::~Constant() { delete type; }
     31
     32Constant Constant::from( int i ) {
     33        return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ) );
     34}
     35
     36Constant Constant::from( unsigned long i ) {
     37        return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ) );
     38}
     39
     40Constant Constant::from( double d ) {
     41        return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ) );
     42}
    3043
    3144Constant *Constant::clone() const { assert( false ); return 0; }
  • src/SynTree/Constant.h

    rdbd8652 r9d7b3ea  
    3232        void set_value( std::string newValue ) { value = newValue; }
    3333
     34        /// generates an integer constant of the given int
     35        static Constant from( int i );
     36        /// generates an integer constant of the given unsigned long int
     37        static Constant from( unsigned long i );
     38        /// generates a floating point constant of the given double
     39        static Constant from( double d );
     40
    3441        virtual Constant *clone() const;
    3542        virtual void accept( Visitor &v ) { v.visit( this ); }
Note: See TracChangeset for help on using the changeset viewer.