/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to src/libvqdr/function/function_token.vala

  • Committer: Gustav Hartvigsson
  • Date: 2021-09-15 08:34:45 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210915083445-51lhp1u690xm20d2
* Fixed the "allowed function token type" map...
* Still unsure if it is even useful... we will have to see...

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
      base (0);
10
10
    }
11
11
    
 
12
    private struct Entry {
 
13
      public string key;
 
14
      public Type? val;
 
15
    }
 
16
    
 
17
    
12
18
    // We only store the type, as that is what is important.
13
19
    private static Gee.HashMap<string, Type?> _allowed_functions;
14
20
    
71
77
    protected const string SYM_TRUNK_END = SYM_END; //"]"
72
78
    
73
79
    construct {
74
 
      _allowed_functions = new Gee.HashMap<string, Type?> ();
75
80
      this.priority = Prio.FUNCTION;
76
81
    }
77
82
    
 
83
    
78
84
    /**
79
85
     * Ititialise the right functon token by it's name.
80
86
     * 
83
89
     * @return An instance representing the function, or @c null if not found.
84
90
     */
85
91
    public static FunctionToken? init_token (string token, int position) {
 
92
      
 
93
      if (_allowed_functions == null) {
 
94
        // Intialise the HashMap if it is not created.
 
95
        _allowed_functions = new Gee.HashMap<string, Type?> ();
 
96
        
 
97
        Entry[] entries = {
 
98
            {"round_up", typeof (RoundUpFunctionToken)},
 
99
            {"round_down", typeof (RoundDownFunctionToken)},
 
100
            {null, null}
 
101
        };
 
102
        
 
103
        foreach (Entry e in entries) {
 
104
          _allowed_functions.@set (e.key, e.val);
 
105
        }
 
106
        
 
107
      }
 
108
      
86
109
      FunctionToken? retval = null;
87
110
      
88
111
      // We get the token type.
135
158
     } else {
136
159
       return FastNumber.raw (default_result);
137
160
     }
 
161
     
138
162
    }
139
 
    
140
 
    
141
 
    
142
163
  }
143
164
}