Changeset 5e0e488 for libcfa


Ignore:
Timestamp:
Aug 31, 2021, 1:49:09 AM (3 years ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
Children:
b532fcf
Parents:
4df8fef5
git-author:
Jacob Prud'homme <jafprudhomme@…> (07/13/21 12:37:35)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:09)
Message:

Created array to hold intermediate format (string, string)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    r4df8fef5 r5e0e488  
    11#include <fstream.hfa>
     2#include <heap.hfa>
    23#include "parseconfig.hfa"
     4
     5struct KVPairs {
     6        int size, max_size;
     7        * [ char *, char * ] data;
     8};
     9void ?{}( VLA & vla ) with ( vla ) {    // default constructor
     10        size = 0; max_size = 0; data = 0p;
     11}
     12void ?{}( VLA & vla, int size, char fill = ['\0', '\0'] ) { // initialization
     13        vla.[ size, max_size, data ] = [ size, max_size, alloc( size, fill ) ];
     14}
     15void ?{}( VLA & vla, VLA val ) with( val ) { // copy, deep
     16        vla.[ size, max_size, data ] = [ size, max_size, alloc( size, data ) ];
     17}
     18void ^?{}( VLA & vla ) with ( vla ) {   // destructor
     19        free( data );
     20        size = 0; max_size = 0; data = 0p;
     21}
     22
     23void add_kv_pair( KVPairs kv_pairs, char * k, char * v ) with( kv_pairs ) {
     24        if ( size == max_size ) {
     25                max_size = max_size * 2;
     26                data = resize( data, max_size );
     27        }
     28
     29        data[size] = [ k, v ];
     30        ++size;
     31}
    332
    433bool comments( ifstream & in, char * name ) {
     
    1443// Process the configuration file to set the simulation parameters.
    1544void parse_config( const char * config_file, config_entry entries[], size_t num_entries ) {
     45        KVPairs kv_pairs{ num_entries };
     46
    1647        ifstream in;
    1748        try {
Note: See TracChangeset for help on using the changeset viewer.