• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can
5  * be found in the LICENSE file.
6  *
7  */
8 
9 #include <stdio.h>
10 #include <stdlib.h>
11 
12 //
13 //
14 //
15 
16 #include "gen.h"
17 
18 //
19 //
20 //
21 
22 #define HSG_INDENT  2
23 
24 //
25 //
26 //
27 
28 struct hsg_target_state
29 {
30   FILE * txt;
31 };
32 
33 //
34 //
35 //
36 
37 void
hsg_target_indent(struct hsg_target * const target,uint32_t const depth)38 hsg_target_indent(struct hsg_target * const target, uint32_t const depth)
39 {
40   fprintf(target->state->txt,
41           "%*s",
42           depth*HSG_INDENT,"");
43 }
44 
45 void
hsg_target_debug(struct hsg_target * const target,struct hsg_config const * const config,struct hsg_merge const * const merge,struct hsg_op const * const ops,uint32_t const depth)46 hsg_target_debug(struct hsg_target       * const target,
47                  struct hsg_config const * const config,
48                  struct hsg_merge  const * const merge,
49                  struct hsg_op     const * const ops,
50                  uint32_t                  const depth)
51 {
52   if (ops->type == HSG_OP_TYPE_TARGET_BEGIN)
53     {
54       target->state = malloc(sizeof(*target->state));
55 
56       target->state->txt = fopen("hs_debug.txt","wb");
57     }
58 
59   hsg_target_indent(target,depth);
60 
61   fprintf(target->state->txt,
62           "%s\n",
63           hsg_op_type_string[ops->type]);
64 
65   if (ops->type == HSG_OP_TYPE_TARGET_END)
66     {
67       fclose(target->state->txt);
68       free(target->state);
69     }
70 }
71 
72 //
73 //
74 //
75