summaryrefslogtreecommitdiff
path: root/macros/SymbolTable/ST_MatchSymbol.sci
blob: 504379c2677be568d8e801636efd9023d7c102d5 (plain)
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
function [TBFlagfound,TBFlagEqualSymbols] = ST_MatchSymbol(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName,MatchRule)
// function [TBFlagfound,TBFlagEqualSymbols] = ST_MatchSymbol(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName,MatchRule)
// -----------------------------------------------------------------
// Match function for the symbol table.
//
// Input data:
// MatchRule: can be 'all','type','size','none'
// //NUT: add description here
//
// Output data:
// TBFlagfound: 0 = if the symbol doesn't exits.
//              1 = the symbol exits.
//              2 = the symbol exists but it is a non-initialized global variable.
// TBFlagEqualSymbols: 0 if the two symbols don't have the same settings,
//                     1 if the two symbols have the same settings.
//
// Status:
// 26-Oct-2007 -- Raffaele Nutricato: Author.
// 26-Oct-2007 -- Alberto Morea: Test Ok.
//
// Copyright 2007 Raffaele Nutricato & Alberto Morea.
// Contact: raffaele.nutricato@tiscali.it
// -----------------------------------------------------------------


// ------------------------------
// --- Check input arguments. ---
// ------------------------------
SCI2CNInArgCheck(argn(2),8,8);

TBFlagfound = 0;
TBFlagEqualSymbols = 0;

// --- Find symbol (If exists). ---
[TBFlagfound,tmpType,tmpSize,tmpValue,tmpFindLike,tmpDimension] = ...
   ST_Get(TBName,SymbolTableFileName);
if (TBFlagfound == 1)
   if (tmpType == 'GBLToBeDefined')
      TBFlagfound = 2;
      TBFlagEqualSymbols = 0; // I don't want to force the error issue in ST_InsOutArg.sci
   else
      // Symbol already exists. Check that it has the same settings of the current output argument.
      TBFlagEqualSymbols = 1;
      if (MatchRule == 'type' | MatchRule == 'all')
         if (mtlb_strcmp(tmpType,TBType) == %F)
            TBFlagEqualSymbols = 0;
         end
      end
      if (MatchRule == 'size' | MatchRule == 'all')
         // First check the dimension.
         if (tmpDimension ~= TBDimension)
            TBFlagEqualSymbols = 0;
         end
         // Then if the size is a number also its value is compared.
         if (isnum(tmpSize(1))) & (isnum(TBSize(1)))
            if (mtlb_strcmp(tmpSize(1),TBSize(1)) == %F)
               TBFlagEqualSymbols = 0;
            end
         end
         if (isnum(tmpSize(2))) & (isnum(TBSize(2)))
            if (mtlb_strcmp(tmpSize(2),TBSize(2)) == %F)
               TBFlagEqualSymbols = 0;
            end
         end
      end
   end
end

endfunction