This file is indexed.

/usr/include/scilab/internal.hxx is in scilab-include 6.0.1-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
/*
*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
*  Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS
*  Copyright (C) 2010-2010 - DIGITEO - Bruno JOFRET
*
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
*
*/


#ifndef __INTERNAL_HXX__
#define __INTERNAL_HXX__

#include <vector>
#include <unordered_map>
#include <iostream>
#include <algorithm>
#include <string>

extern "C"
{
#include "dynlib_ast.h"
#include "configvariable_interface.h"
}

#include "localization.hxx"
#ifndef NDEBUG
#include "inspector.hxx"
#endif

#define bsiz 4096

//#define _SCILAB_DEBUGREF_
#ifdef _SCILAB_DEBUGREF_
//#define _SCILAB_DEBUGREF_WITHOUT_START_END
#define DecreaseRef() _decreaseref(__FILE__, __LINE__)
#define IncreaseRef() _increaseref(__FILE__, __LINE__)
#define killMe() _killme(__FILE__, __LINE__)
#endif

#include "visitor.hxx"

class Location;

namespace types
{

/*
** List of types
*/
class InternalType;
typedef std::vector<InternalType *> typed_list;
typedef std::unordered_map<std::wstring, InternalType *> optional_list;

class EXTERN_AST InternalType
{
public :
    enum ScilabType
    {
        ScilabNull = 0, //no type, no data, nothing !
        /* Internal Type */
        ScilabInternal,
        /* Generic Types */
        ScilabGeneric,
        ScilabInt8,
        ScilabUInt8,
        ScilabInt16,
        ScilabUInt16,
        ScilabInt32,
        ScilabUInt32,
        ScilabInt64,
        ScilabUInt64,
        ScilabString,
        ScilabDouble,
        ScilabBool,
        ScilabFloat,
        ScilabPolynom,
        ScilabSinglePolynom,
        /* Callable */
        ScilabFunction,
        ScilabMacro,
        ScilabMacroFile,
        /* Implicit List */
        ScilabImplicitList,
        /* Container */
        ScilabContainer,
        ScilabList,
        ScilabTList,
        ScilabMList,
        ScilabSingleStruct,
        ScilabStruct,
        ScilabCell,
        /* User */
        ScilabUserType,
        /*For list operation*/
        ScilabListOperation, //parent type
        ScilabListInsertOperation,
        ScilabListDeleteOperation,
        ScilabListUndefinedOperation,
        ScilabFile,
        ScilabColon,
        ScilabThreadId,
        ScilabSparse,
        ScilabSparseBool,
        ScilabHandle,
        ScilabVoid,
        ScilabLibrary
    };

    enum ScilabId
    {
        IdNull, //no type, no data, nothing !
        /* Internal Type */
        IdInternal,
        /* Generic Types */
        IdGeneric,
        IdEmpty,
        IdIdentity,
        IdIdentityComplex,
        IdInt8,
        IdScalarInt8,
        IdUInt8,
        IdScalarUInt8,
        IdInt16,
        IdScalarInt16,
        IdUInt16,
        IdScalarUInt16,
        IdInt32,
        IdScalarInt32,
        IdUInt32,
        IdScalarUInt32,
        IdInt64,
        IdScalarInt64,
        IdUInt64,
        IdScalarUInt64,
        IdString,
        IdScalarString,
        IdDouble,
        IdDoubleComplex,
        IdScalarDouble,
        IdScalarDoubleComplex,
        IdBool,
        IdScalarBool,
        IdPolynom,
        IdScalarPolynomComplex,
        IdScalarPolynom,
        IdPolynomComplex,
        IdSinglePolynom,
        /* Callable */
        IdFunction,
        IdMacro,
        IdMacroFile,
        /* Implicit List */
        IdImplicitList,
        /* Container */
        IdContainer,
        IdList,
        IdTList,
        IdMList,
        IdSingleStruct,
        IdStruct,
        IdCell,
        /* User */
        IdUserType,
        /*For list operation*/
        IdListOperation, //parent type
        IdListInsertOperation,
        IdListDeleteOperation,
        IdListUndefinedOperation,
        IdFile,
        IdColon,
        IdThreadId,
        IdSparse,
        IdSparseComplex,
        IdSparseBool,
        IdHandle,
        IdScalarHandle,
        IdVoid,
        IdLibrary,
        IdLast //msut always be the last value
    };

protected :
    InternalType() : m_iRef(0), m_bAllowDelete(true), m_bPrintFromStart(true), m_iSavePrintState(0), m_iRows1PrintState(0), m_iCols1PrintState(0), m_iRows2PrintState(0), m_iCols2PrintState(0), bKillMe(false)
    {
#ifdef _SCILAB_DEBUGREF_
#if defined(_SCILAB_DEBUGREF_WITHOUT_START_END)
        if (getStartProcessing() == 0 && getEndProcessing() == 0)
#endif
        {
            std::cout << "new_IT " << m_iRef << " " << (void*)this << std::endl;
        }
#endif
    }

public :

    virtual                         ~InternalType()
    {
#ifdef _SCILAB_DEBUGREF_
#if defined(_SCILAB_DEBUGREF_WITHOUT_START_END)
        if (getStartProcessing() == 0 && getEndProcessing() == 0 && bKillMe == false)
#endif
        {
            std::cout << "delete_IT " << m_iRef << " " << (void*)this << std::endl;
        }
#endif
    }

    virtual void                    whoAmI(void);
    virtual bool                    isAssignable(void);
    virtual ScilabType              getType(void) = 0 ; //{ return ScilabInternal; }
    virtual ScilabId                getId(void) = 0 ; //{ return ScilabInternal; }
    virtual bool                    hasToString();
    virtual bool                    toString(std::wostringstream& ostr) = 0;
    virtual std::wstring            toStringInLine();
    virtual InternalType*           clone(void) = 0;
    virtual ast::Exp*               getExp(const Location& /*loc*/);

    template <typename T, typename F, typename ... A>
    T* checkRef(T* _pIT, F f, A ... a)
    {
        if (getRef() > 1)
        {
            // A types:: content in more than one Scilab variable
            // must be cloned before being modified.
            T* pClone = _pIT->clone()->template getAs<T>();
            T* pIT = (pClone->*f)(a...);
            if (pIT == NULL)
            {
                pClone->killMe();
            }

            return pIT;
        }

        return _pIT;
    }



#ifdef _SCILAB_DEBUGREF_
    inline void _killme(const char * f, int l)
    {
#if defined(_SCILAB_DEBUGREF_WITHOUT_START_END)
        if (getStartProcessing() == 0 && getEndProcessing() == 0)
#endif
        {
            std::cout << "killme " << m_iRef << " " << (void*)this << " in " << f << " at line " << l << std::endl;
        }

        if (isDeletable())
        {
            bKillMe = true;
            delete this;
        }
    }

    inline void _increaseref(const char * f, int l)
    {
        m_iRef++;
#if defined(_SCILAB_DEBUGREF_WITHOUT_START_END)
        if (getStartProcessing() == 0 && getEndProcessing() == 0)
#endif
        {
            std::cout << "incref " << m_iRef << " " << (void*)this << " in " << f << " at line " << l << std::endl;
        }
    }

    inline void _decreaseref(const char * f, int l)
    {
        if (m_iRef > 0)
        {
            m_iRef--;
        }

#if defined(_SCILAB_DEBUGREF_WITHOUT_START_END)
        if (getStartProcessing() == 0 && getEndProcessing() == 0)
#endif
        {
            std::cout << "decref " << m_iRef << " " << (void*)this << " in " << f << " at line " << l << std::endl;
        }
    }
#else

    inline void killMe()
    {
        if (isDeletable())
        {
            delete this;
        }
    }

    inline void IncreaseRef()
    {
        m_iRef++;
    }

    inline void DecreaseRef()
    {
        if (m_iRef > 0)
        {
            m_iRef--;
        }
    }
#endif

    inline bool isDeletable()
    {
        return m_iRef == 0;
    }

    inline bool isRef(int _iRef = 0)
    {
        return m_iRef > _iRef;
    }

    inline int getRef() const
    {
        return m_iRef;
    }

    virtual bool isTrue();
    virtual bool neg(InternalType *& /*out*/);
    virtual bool transpose(InternalType *& /*out*/);
    virtual bool adjoint(InternalType *& out);
    virtual bool isFieldExtractionOverloadable() const;
    virtual bool invoke(typed_list & /*in*/, optional_list & /*opt*/, int /*_iRetCount*/, typed_list & /*out*/, const ast::Exp & /*e*/);
    virtual bool isInvokable() const;
    virtual bool hasInvokeOption() const;
    virtual int getInvokeNbIn();
    virtual int getInvokeNbOut();
    /* return type as string ( double, int, cell, list, ... )*/
    virtual std::wstring            getTypeStr() const = 0;
    /* return type as short string ( s, i, ce, l, ... )*/
    virtual std::wstring            getShortTypeStr() const = 0;
    virtual bool                    operator==(const InternalType& it);
    virtual bool                    operator!=(const InternalType& it);

    /**
    ** GenericType
    ** \{
    */

    template <class T>
    inline T*                              getAs(void)
    {
        return static_cast<T*>(this);
    }

    virtual bool isGenericType(void);
    virtual bool isArrayOf(void);
    virtual bool isString(void);
    virtual bool isDouble(void);
    virtual bool isSparse(void);
    virtual bool isSparseBool(void);
    virtual bool isFloat(void);
    virtual bool isInt(void);
    virtual bool isInt8(void);
    virtual bool isUInt8(void);
    virtual bool isInt16(void);
    virtual bool isUInt16(void);
    virtual bool isInt32(void);
    virtual bool isUInt32(void);
    virtual bool isInt64(void);
    virtual bool isUInt64(void);
    virtual bool isBool(void);
    virtual bool isPoly(void);
    virtual bool isSinglePoly(void);
    virtual bool isCallable(void);
    virtual bool isFunction(void);
    virtual bool isMacro(void);
    virtual bool isMacroFile(void);
    virtual bool isContainer(void);
    virtual bool isList(void);
    virtual bool isStruct(void);
    virtual bool isSingleStruct(void);
    virtual bool isCell(void);
    virtual bool isTList(void);
    virtual bool isMList(void);
    virtual bool isImplicitList(void);
    virtual bool isColon(void);
    virtual bool isDollar(void);
    virtual bool isFile(void);
    virtual bool isHandle(void);
    virtual bool isSingleHandle(void);
    virtual bool isThreadId(void);
    virtual bool isListOperation(void);
    virtual bool isListDelete(void);
    virtual bool isListInsert(void);
    virtual bool isListUndefined(void);
    virtual bool isPointer(void);
    virtual bool isLibrary(void);
    virtual bool isUserType(void);

    void clearPrintState();

protected :
    int          m_iRef;
    //use to know if we can delete this variables or if it's link to a scilab variable.
    bool         m_bAllowDelete;

    /*variables to manage print taking care of lines*/
    bool m_bPrintFromStart;
    int  m_iSavePrintState;
    int  m_iRows1PrintState;
    int  m_iCols1PrintState;
    int  m_iRows2PrintState;
    int  m_iCols2PrintState;

    bool bKillMe;

};

}

#ifdef _SCILAB_DEBUGREF_
#undef _SCILAB_DEBUGREF_
#endif

#endif /* !__INTERNAL_HXX__ */