File:  [Coherent Logic Development] / freem / src / symtab_dispatch.c
Revision 1.7: download - view: text, annotated - select for diffs
Mon Apr 28 19:38:55 2025 UTC (3 months ago) by snw
Branches: MAIN
CVS tags: HEAD
Add trace mode

    1: /*
    2:  *   $Id: symtab_dispatch.c,v 1.7 2025/04/28 19:38:55 snw Exp $
    3:  *    symbol table dispatch module
    4:  *
    5:  *  
    6:  *   Author: Serena Willis <snw@coherent-logic.com>
    7:  *    Copyright (C) 1998 MUG Deutschland
    8:  *    Copyright (C) 2020, 2025 Coherent Logic Development LLC
    9:  *
   10:  *
   11:  *   This file is part of FreeM.
   12:  *
   13:  *   FreeM is free software: you can redistribute it and/or modify
   14:  *   it under the terms of the GNU Affero Public License as published by
   15:  *   the Free Software Foundation, either version 3 of the License, or
   16:  *   (at your option) any later version.
   17:  *
   18:  *   FreeM is distributed in the hope that it will be useful,
   19:  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   20:  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   21:  *   GNU Affero Public License for more details.
   22:  *
   23:  *   You should have received a copy of the GNU Affero Public License
   24:  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
   25:  *
   26:  *   $Log: symtab_dispatch.c,v $
   27:  *   Revision 1.7  2025/04/28 19:38:55  snw
   28:  *   Add trace mode
   29:  *
   30:  *   Revision 1.6  2025/04/28 14:52:54  snw
   31:  *   Temporarily revert global handler refactor and fix reference regression in xecline
   32:  *
   33:  *   Revision 1.5  2025/04/13 04:22:43  snw
   34:  *   Fix snprintf calls
   35:  *
   36:  *   Revision 1.4  2025/03/27 03:27:35  snw
   37:  *   Install init scripts to share/freem/examples/init and fix regression in method dispatch
   38:  *
   39:  *   Revision 1.3  2025/03/09 19:50:47  snw
   40:  *   Second phase of REUSE compliance and header reformat
   41:  *
   42:  *
   43:  * SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
   44:  * SPDX-License-Identifier: AGPL-3.0-or-later
   45:  **/
   46: 
   47: #include <string.h>
   48: #include <ctype.h>
   49: #include "mpsdef.h"
   50: #include "mref.h"
   51: #include "objects.h"
   52: 
   53: void symtab (short action, char *key, char *data)
   54: {
   55:     register int i;
   56:     register int j;
   57:     char ch;
   58: 
   59:     short res;
   60:     char obj_class[255];
   61:     char t_rou[255];
   62:     char t_cls[255];
   63:     
   64:     freem_ref_t rv;
   65:     freem_ref_t *r = &rv;
   66: 
   67:     mref_init (r, MREF_RT_LOCAL, "");
   68:     internal_to_mref (r, key);
   69: 
   70:     /*
   71:     res = obj_is_object (r->name);    
   72: 
   73:     if (res == TRUE) {
   74:         res = obj_get_attribute (r->name, "CLASS", obj_class);
   75:         stcpy (t_rou, rou_name);
   76:         stcnv_m2c (t_rou);
   77:         strcpy (t_cls, &(obj_class[1]));
   78:         
   79:         if ((strcmp (t_rou, t_cls) != 0) && (obj_is_field_private (key) == TRUE)) {
   80:             merr_raise (OBJFLDACCV);
   81:             return;
   82:         }        
   83: 
   84:         if (r->subscript_count == 0 && action == kill_sym) {
   85:             
   86:             if (destructor_ct < 10) {                
   87:                 snprintf (destructors[destructor_ct++], OBJ_DSTRSIZE - 1, "DESTROY^%%SYSOOP(\"%s\",.%s)", t_cls, r->name);
   88:             }
   89:             
   90:             obj_destroy (key);
   91:             
   92:         }
   93:         
   94:     }
   95:     */
   96:     
   97:     if (action != fra_order && action != fra_query) {
   98:         for (i = 0; i < r->subscript_count; i++) {
   99:             
  100:             if (strlen (r->subscripts[i]) < 1) {
  101:                 merr_raise (SBSCR);
  102:                 return;
  103:             }
  104:             
  105:         }
  106:     }
  107: 
  108:     if (rtn_dialect () == D_M77) {
  109: 
  110:         for (i = 0; i < r->subscript_count; i++) {
  111:             for (j = 0; j < strlen (r->subscripts[i]); j++) {
  112: 
  113:                 ch = r->subscripts[i][j];
  114: 
  115:                 if (!isdigit (ch)) {
  116:                     merr_raise (NOSTAND);
  117:                     return;
  118:                 }
  119:                 
  120:             }
  121:         }
  122: 
  123:     }
  124:     
  125:     symtab_bltin (action, key, data);
  126:     
  127: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>