• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 21192220067

21 Jan 2026 12:15AM UTC coverage: 55.577% (-0.003%) from 55.58%
21192220067

Pull #2028

github

web-flow
Merge f43251a11 into 771012348
Pull Request #2028: Fixed the condition for stl only case so char* or char[] size calculation gets to normal handling

1 of 3 new or added lines in 1 file covered. (33.33%)

125 existing lines in 5 files now uncovered.

12506 of 22502 relevant lines covered (55.58%)

296541.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.52
/trick_source/sim_services/MemoryManager/ref_parser.y
1
%name-prefix="REF_"
2
%pure-parser
3
%locations
4
%parse-param {RefParseContext* context}
5
%lex-param { void* scanner }
6
%{
7

8
/*
9
   %debug
10
   %error-verbose
11
 */
12

13
#include <iostream>
14
#include <sstream>
15
#include <stdlib.h>
16
#include <string.h>
17

18
#include "trick/RefParseContext.hh"
19
#include "trick/vval.h"
20
#include "trick/value.h"
21
#include "trick/var.h"
22
#include "ref_parser.tab.hpp"
23

24
#pragma GCC diagnostic ignored "-Wunused-parameter"
25

26
    using namespace std;
27

28
    int REF_lex( YYSTYPE* lvalp, YYLTYPE* llocp, void* scanner );
29
 
30
    void REF_error( YYLTYPE* locp, RefParseContext* context __attribute__ ((unused)) , const char* err) {
1✔
31
        std::stringstream message;
1✔
32
        message << "Syntax error: " << locp->first_line << " : " << err ;
1✔
33
        Trick::MemoryManager::emitError(message.str());
1✔
34
    }
1✔
35

36
#define scanner context->scanner
37
#ifdef YYDEBUG
38
#undef YYDEBUG
39
#endif
40
#define YYDEBUG 1
41
%}
42

43
%start reference
44

45
%union {
46
    char*  sval  ;
47
    int    ival  ;
48
    V_DATA vval ;
49
    REF2   rval ;
50
}
51

52
%token <sval> NAME 
53
%token <ival> I_CON
54

55
%token ARROW
56

57
%token END 0 "End of file"
58

59
%type  <vval> v_data 
60
%type  <rval> param reference 
61
%type  <ival> dereference 
62

63
%%
64

65
reference: param { 
66
        /*
67
         * This rule handles the collection of parameter name information.
68
         * When this rule fires the I->reference parameter, of type REF,
69
         * (same type used through io_* functions), is ready to be sent to
70
         * ref_attributes()
71
         */
72

73
          $$ = $1 ;
13,024✔
74
          context->result = (REF2*)malloc( sizeof(REF2));
13,024✔
75
          memcpy( context->result, &$1, sizeof(REF2));
13,024✔
76
}
77
;
78

79
param: NAME {
80
    /* 
81
     * This rule handles anything that starts with a NAME.  That includes
82
     * parameters, input file variables, defines, enumerations, and
83
     * sizeof structure types.
84
     * This first rule will return a reference if the variable is a
85
     * parameter or a variable.
86
     */
87

88
    int ret;
89

90
    $$.reference = NULL;
13,140✔
91
    $$.num_index = 0;
13,140✔
92
    $$.units = NULL;
13,140✔
93
    $$.pointer_present = 0;
13,140✔
94
    $$.ref_type = REF_ADDRESS;
13,140✔
95
    $$.create_add_path = 1 ;
13,140✔
96
    $$.address_path = DLL_Create() ;
13,140✔
97

98
    // Get the address and attrs of the variable.
99
    if ((ret = context->mem_mgr->ref_var( &$$, $1)) != MM_OK) {
13,140✔
100
        return ( ret);
114✔
101
    }
102

103
    $$.num_index_left = $$.attr->num_index;
13,026✔
104
    $$.reference = $1 ;
13,026✔
105

106
}
107
| '&' NAME {
108
    /*
109
     * This rule handles the first name with a preceding address character.
110
     * Only parameters and vars are allowed to have a preceding "&" char.
111
     */
112

113
      int ret;
114

UNCOV
115
      $$.reference = NULL;
×
116
      $$.num_index = 0;
×
117
      $$.units = NULL;
×
118
      $$.pointer_present = 0;
×
119
      $$.ref_type = REF_ADDRESS;
×
120
      $$.create_add_path = 1 ;
×
121
      $$.address_path = DLL_Create() ;
×
122

123
    // Get the address and attrs of the variable.
UNCOV
124
    if ((ret = context->mem_mgr->ref_var( &$$, $2)) != MM_OK) {
×
UNCOV
125
        std::stringstream message;
×
126
        message << "MemoryManager ERROR: Invalid reference: \"" << $2 << "\".";
×
127
        Trick::MemoryManager::emitError(message.str());
×
128
        return ( ret);
×
129
    }
130

UNCOV
131
    $$.num_index_left = $$.attr->num_index;
×
132
    //$$.reference = strdup($2) ;
133

134
}
135
| param '[' v_data ']' {
136

137
    int ret;
138

139
    if ((ret = context->mem_mgr->ref_dim(&$$, &$3)) != MM_OK) {
9,800✔
140
        return (ret);
1✔
141
    }
142

143
}
144
| param dereference NAME {
145

146
    /* This rule handles every name level after the first with a "->" or "." */
147
    int ret;
148
    char temp[512];
149

150
    if ( $2 == 1) {
2,509✔
151
        // we have an ARROW, so dereference the address.
152
        $$.address = *(void**)$$.address;
3✔
153
        $$.num_index ++; 
3✔
154
    }
155

156
    /* Check to see if previous parameter specified enough dimensions. */
157
    if ($$.num_index != $$.attr->num_index) {
2,509✔
UNCOV
158
        std::stringstream message;
×
UNCOV
159
        message << "Dimension mismatch.";
×
160
        Trick::MemoryManager::emitError(message.str());
×
161
        return (MM_PARAMETER_ARRAY_DIM);
×
162
    }
163

164
    $$.num_index = 0;
2,509✔
165

166
    if ((ret = context->mem_mgr->ref_name(&$$, $3)) != MM_OK) {
2,509✔
167
        return (ret);
1✔
168
    }
169

170
    /* create a new reference string because previous nodes may refer to old strings */
171
    $$.num_index_left = $$.attr->num_index;
2,508✔
172

173
    snprintf(temp, sizeof(temp), "%s.%s" , $$.reference, $3) ;
2,508✔
174

175
    $$.reference = (char*)realloc($$.reference, strlen(temp) + 1) ;
2,508✔
176
    strcpy($$.reference , temp) ;
2,508✔
177

178
    free($3);
2,508✔
179

180
} ;
181

182
dereference: ARROW {
183
        $$ = 1 ;
3✔
184
           }
185
           | '.' {
186
        $$ = 0 ;
2,506✔
187
           };
188

189
v_data:
190
    I_CON { 
191
        /*
192
         * Do not convert to double to ensure that there is no loss of precision
193
         */
194
        $$.value.i = $1 ;
9,800✔
195
        $$.type = TRICK_INTEGER ;
9,800✔
196
    }
197
    ;
198

199
%%
200

201

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc