Changeset 4040425 for src/examples


Ignore:
Timestamp:
Mar 2, 2016, 6:15:02 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, b63e376
Parents:
8f610e85
Message:

change keyword type to otype and context to trait

Location:
src/examples
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/examples/array.c

    r8f610e85 r4040425  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:10:13 2015
    13 // Update Count     : 2
     12// Last Modified On : Wed Mar  2 18:13:52 2016
     13// Update Count     : 3
    1414//
    1515
    1616#include "array.h"
    1717
    18 /// forall( type array_type, elt_type | bounded_array( array_type, elt_type ) )
     18/// forall( otype array_type, elt_type | bounded_array( array_type, elt_type ) )
    1919/// [ array_iterator begin, array_iterator end ]
    2020/// get_iterators( array_type array )
     
    2525
    2626// The first element is always at index 0.
    27 forall( type array_type, type elt_type | bounded_array( array_type, elt_type ) )
     27forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) )
    2828elt_type * begin( array_type array ) {
    2929        return &array[ 0 ];
     
    3131
    3232// The end iterator should point one past the last element.
    33 forall( type array_type, type elt_type | bounded_array( array_type, elt_type ) )
     33forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) )
    3434elt_type * end( array_type array ) {
    3535        return &array[ last( array ) ] + 1;
  • src/examples/array.h

    r8f610e85 r4040425  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jan 26 17:09:29 2016
    13 // Update Count     : 3
     12// Last Modified On : Wed Mar  2 18:13:35 2016
     13// Update Count     : 5
    1414//
    1515
     
    2121// An array has contiguous elements accessible in any order using integer indicies. The first
    2222// element has index 0.
    23 context array( type array_type, type elt_type ) {
     23trait array( otype array_type, otype elt_type ) {
    2424        lvalue elt_type ?[?]( array_type, int );
    2525};
    2626
    2727// A bounded array is an array that carries its maximum index with it.
    28 context bounded_array( type array_type, type elt_type | array( array_type, elt_type ) ) {
     28trait bounded_array( otype array_type, otype elt_type | array( array_type, elt_type ) ) {
    2929        int last( array_type );
    3030};
     
    3434typedef int array_iterator;
    3535
    36 /// forall( type array_type, elt_type | bounded_array( array_type, elt_type ) )
     36/// forall( otype array_type, elt_type | bounded_array( array_type, elt_type ) )
    3737/// [ array_iterator begin, array_iterator end ] get_iterators( array_type );
    3838
     
    4040// A bounded array can be iterated over by using a pointer to the element type. These functions
    4141// return iterators corresponding to the first element and the one-past-the-end element, STL-style.
    42 forall( type array_type, type elt_type | bounded_array( array_type, elt_type ) )
     42forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) )
    4343elt_type *begin( array_type );
    4444
    45 forall( type array_type, type elt_type | bounded_array( array_type, elt_type ) )
     45forall( otype array_type, otype elt_type | bounded_array( array_type, elt_type ) )
    4646elt_type *end( array_type );
    4747
  • src/examples/ctxts.c

    r8f610e85 r4040425  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:11:19 2015
    13 // Update Count     : 2
     12// Last Modified On : Wed Mar  2 18:10:21 2016
     13// Update Count     : 3
    1414//
    1515
    16 context has_f( type T ) {
     16trait has_f( type T ) {
    1717        T f( T );
    1818};
    1919
    20 context has_g( type U | has_f( U ) ) {
     20trait has_g( type U | has_f( U ) ) {
    2121        U g( U );
    2222};
  • src/examples/index.h

    r8f610e85 r4040425  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:17:31 2015
    13 // Update Count     : 1
     12// Last Modified On : Wed Mar  2 18:10:46 2016
     13// Update Count     : 2
    1414//
    1515
    16 context index( type T ) {
     16trait index( type T ) {
    1717        T ?+?( T, T );
    1818        T ?-?( T, T );
  • src/examples/it_out.c

    r8f610e85 r4040425  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:41:23 2015
    13 // Update Count     : 4
     12// Last Modified On : Wed Mar  2 18:11:00 2016
     13// Update Count     : 5
    1414//
    1515
    1616typedef unsigned long streamsize_type;
    1717
    18 context ostream( dtype os_type ) {
     18trait ostream( dtype os_type ) {
    1919        os_type *write( os_type *, const char *, streamsize_type );
    2020        int fail( os_type * );
    2121};
    2222
    23 context writeable( type T ) {
     23trait writeable( type T ) {
    2424        forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, T );
    2525};
     
    2929forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, const char * );
    3030
    31 context istream( dtype is_type ) {
     31trait istream( dtype is_type ) {
    3232        is_type *read( is_type *, char *, streamsize_type );
    3333        is_type *unread( is_type *, char );
     
    3636};
    3737
    38 context readable( type T ) {
     38trait readable( type T ) {
    3939        forall( dtype is_type | istream( is_type ) ) is_type * ?<<?( is_type *, T );
    4040};
     
    4343forall( dtype is_type | istream( is_type ) ) is_type * ?>>?( is_type *, int* );
    4444
    45 context iterator( type iterator_type, type elt_type ) {
     45trait iterator( type iterator_type, type elt_type ) {
    4646        iterator_type ?++( iterator_type* );
    4747        iterator_type ++?( iterator_type* );
  • src/examples/prolog.c

    r8f610e85 r4040425  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 27 18:25:52 2015
    13 // Update Count     : 1
     12// Last Modified On : Wed Mar  2 18:11:18 2016
     13// Update Count     : 2
    1414//
    1515
     
    2525void is_integer( int x ) {}
    2626
    27 context ArithmeticType( type T ) {
     27trait ArithmeticType( type T ) {
    2828        void is_arithmetic( T );
    2929};
    3030
    31 context IntegralType( type T | ArithmeticType( T ) ) {
     31trait IntegralType( type T | ArithmeticType( T ) ) {
    3232        void is_integer( T );
    3333};
  • src/examples/sum.c

    r8f610e85 r4040425  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 14:31:45 2016
    13 // Update Count     : 193
     12// Last Modified On : Wed Mar  2 18:12:01 2016
     13// Update Count     : 194
    1414//
    1515
    1616#include <fstream>
    1717
    18 context sumable( type T ) {
     18trait sumable( type T ) {
    1919        const T 0;
    2020        T ?+?( T, T );
Note: See TracChangeset for help on using the changeset viewer.