Branch: Tag:

1997-01-30

1997-01-30 03:51:37 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

many optimizations added (see Changelog)

Rev: src/builtin_functions.c:1.25
Rev: src/docode.c:1.10
Rev: src/interpret.c:1.23
Rev: src/language.yacc:1.21
Rev: src/las.c:1.16
Rev: src/lex.c:1.14
Rev: src/lex.h:1.3
Rev: src/peep.c:1.5
Rev: src/peep.in:1.3
Rev: src/pike_types.c:1.15
Rev: src/port.h:1.11

4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: lex.c,v 1.13 1997/01/27 01:20:04 hubbe Exp $"); + RCSID("$Id: lex.c,v 1.14 1997/01/30 03:51:34 hubbe Exp $");   #include "language.h"   #include "array.h"   #include "lex.h"
57:   void exit_lex()   {   #ifdef DEBUG -  if(p_flag > 2) +  if(p_flag)    {    int e;    fprintf(stderr,"Opcode usage: (opcode, runned, compiled)\n");
144:   { "!=", F_NE },   { "%", F_MOD },   { "%=", F_MOD_EQ }, - { "& global", F_GLOBAL_LVALUE }, - { "& local", F_LOCAL_LVALUE }, + { "& global", F_GLOBAL_LVALUE, 1 }, + { "& local", F_LOCAL_LVALUE, 1 },   { "&", F_AND }, - { "&&", F_LAND }, + { "&&", F_LAND, 1 },   { "&=", F_AND_EQ },   { "*", F_MULTIPLY },   { "*=", F_MULT_EQ },   { "+", F_ADD }, - { "++Loop", F_INC_LOOP }, - { "++Loop!=", F_INC_NEQ_LOOP }, + { "++Loop", F_INC_LOOP, 1 }, + { "++Loop!=", F_INC_NEQ_LOOP, 1 },   { "++x", F_INC },   { "+=", F_ADD_EQ },   { "-", F_SUBTRACT }, - { "-", F_SUBTRACT }, - { "--Loop", F_DEC_LOOP }, - { "--Loop!=", F_DEC_NEQ_LOOP }, + { "--Loop", F_DEC_LOOP, 1 }, + { "--Loop!=", F_DEC_NEQ_LOOP, 1 },   { "--x", F_DEC },   { "-=", F_SUB_EQ },   { "/", F_DIVIDE },
176:   { "@", F_PUSH_ARRAY },   { "^", F_XOR },   { "^=", F_XOR_EQ }, - { "add 1024 to opcode", F_ADD_1024 }, - { "add 256 to opcode", F_ADD_256 }, - { "add 512 to opcode", F_ADD_512 }, - { "add 768 to opcode", F_ADD_768 }, - { "add X*256 to opcode",F_ADD_256X }, +    { "arg+=1024", F_PREFIX_1024 },   { "arg+=256", F_PREFIX_256 },   { "arg+=256*X", F_PREFIX_CHARX256 },
189:   { "arg+=512", F_PREFIX_512 },   { "arg+=768", F_PREFIX_768 },   { "assign and pop", F_ASSIGN_AND_POP }, - { "assign global", F_ASSIGN_GLOBAL }, - { "assign global and pop", F_ASSIGN_GLOBAL_AND_POP }, - { "assign local", F_ASSIGN_LOCAL }, - { "assign local and pop", F_ASSIGN_LOCAL_AND_POP }, + { "assign global", F_ASSIGN_GLOBAL, 1 }, + { "assign global and pop", F_ASSIGN_GLOBAL_AND_POP, 1 }, + { "assign local", F_ASSIGN_LOCAL, 1 }, + { "assign local and pop", F_ASSIGN_LOCAL_AND_POP, 1 },   { "assign", F_ASSIGN }, - { "branch non zero", F_BRANCH_WHEN_NON_ZERO }, - { "branch when zero", F_BRANCH_WHEN_ZERO }, + { "branch non zero", F_BRANCH_WHEN_NON_ZERO, 1 }, + { "branch when zero", F_BRANCH_WHEN_ZERO, 1 },   { "break", F_BREAK },   { "case", F_CASE },   { "cast", F_CAST }, - { "catch", F_CATCH }, + { "catch", F_CATCH, 1 },   { "const-1", F_CONST_1 }, - { "constant", F_CONSTANT }, + { "constant", F_CONSTANT, 1 },   { "continue", F_CONTINUE },   { "copy_value", F_COPY_VALUE },   { "default", F_DEFAULT },
209:   { "dumb return", F_DUMB_RETURN },   { "float number", F_FLOAT },   { "for", F_FOR }, - { "foreach", F_FOREACH }, - { "global", F_GLOBAL }, + { "foreach", F_FOREACH, 1 }, + { "global", F_GLOBAL, 1 },   { "index", F_INDEX }, - { "->", F_ARROW }, + { "->", F_ARROW, 1 },   { "clear string subtype", F_CLEAR_STRING_SUBTYPE }, - { "arrow string", F_ARROW_STRING }, + { "arrow string", F_ARROW_STRING, 1 },   { "indirect", F_INDIRECT }, - { "jump", F_BRANCH }, - { "local function call",F_CALL_LFUN }, - { "local function call and pop",F_CALL_LFUN_AND_POP }, - { "local function", F_LFUN }, - { "local", F_LOCAL }, + { "jump", F_BRANCH, 1 }, + { "local function call",F_CALL_LFUN, 1 }, + { "local function call and pop",F_CALL_LFUN_AND_POP, 1 }, + { "local function", F_LFUN, 1 }, + { "local", F_LOCAL, 1 }, + { "mark & local", F_MARK_AND_LOCAL, 1 },   { "ltosval2", F_LTOSVAL2 },   { "lvalue to svalue", F_LTOSVAL },   { "lvalue_list", F_LVALUE_LIST },   { "mark", F_MARK },   { "mark mark", F_MARK2 }, - { "negative number", F_NEG_NUMBER }, - { "number", F_NUMBER }, + { "negative number", F_NEG_NUMBER, 1 }, + { "number", F_NUMBER, 1 },   { "pop", F_POP_VALUE }, - { "pop_n_elems", F_POP_N_ELEMS }, + { "pop_n_elems", F_POP_N_ELEMS, 1 },   { "push 0", F_CONST0 },   { "push 1", F_CONST1 },   { "push 0x7fffffff", F_BIGNUM },   { "range", F_RANGE },   { "return", F_RETURN },   { "return 0", F_RETURN_0 }, - { "sscanf", F_SSCANF }, - { "string", F_STRING }, - { "switch", F_SWITCH }, + { "sscanf", F_SSCANF, 1 }, + { "string", F_STRING, 1 }, + { "switch", F_SWITCH, 1 },   { "unary minus", F_NEGATE },   { "while", F_WHILE },   { "x++ and pop", F_INC_AND_POP },
247:   { "x--", F_POST_DEC },   { "|", F_OR },   { "|=", F_OR_EQ }, - { "||", F_LOR }, + { "||", F_LOR, 1 },   { "~", F_COMPL }, - { "label", F_LABEL }, - { "data", F_POINTER }, - { "align", F_ALIGN }, - { "call", F_APPLY }, - { "clear local", F_CLEAR_LOCAL }, - { "++local", F_INC_LOCAL }, - { "++local and pop", F_INC_LOCAL_AND_POP }, - { "local++", F_POST_INC_LOCAL }, - { "--local", F_DEC_LOCAL }, - { "--local and pop", F_DEC_LOCAL_AND_POP }, - { "local--", F_POST_DEC_LOCAL }, - { "branch if <", F_BRANCH_WHEN_LT }, - { "branch if >", F_BRANCH_WHEN_GT }, - { "branch if <=", F_BRANCH_WHEN_LE }, - { "branch if >=", F_BRANCH_WHEN_GE }, - { "branch if ==", F_BRANCH_WHEN_EQ }, - { "branch if !=", F_BRANCH_WHEN_NE }, + { "label", F_LABEL,1 }, + { "data", F_POINTER, 1 }, + { "align", F_ALIGN, 1 }, + { "call", F_APPLY, 1 }, + { "clear local", F_CLEAR_LOCAL, 1 }, + { "clear 2 local", F_CLEAR_2_LOCAL, 1 }, + { "++local", F_INC_LOCAL, 1 }, + { "++local and pop", F_INC_LOCAL_AND_POP, 1 }, + { "local++", F_POST_INC_LOCAL, 1 }, + { "--local", F_DEC_LOCAL, 1 }, + { "--local and pop", F_DEC_LOCAL_AND_POP, 1 }, + { "local--", F_POST_DEC_LOCAL, 1 }, + { "branch if <", F_BRANCH_WHEN_LT, 1 }, + { "branch if >", F_BRANCH_WHEN_GT, 1 }, + { "branch if <=", F_BRANCH_WHEN_LE, 1 }, + { "branch if >=", F_BRANCH_WHEN_GE, 1 }, + { "branch if ==", F_BRANCH_WHEN_EQ, 1 }, + { "branch if !=", F_BRANCH_WHEN_NE, 1 },   { "sizeof", F_SIZEOF }, - { "sizeof local", F_SIZEOF_LOCAL }, + { "sizeof local", F_SIZEOF_LOCAL, 1 },   { "throw(0)", F_THROW_ZERO }, - { "string index", F_STRING_INDEX }, - { "local index", F_LOCAL_INDEX }, - { "int index", F_POS_INT_INDEX }, - { "-int index", F_NEG_INT_INDEX }, + { "string index", F_STRING_INDEX, 1 }, + { "local index", F_LOCAL_INDEX, 1 }, + { "int index", F_POS_INT_INDEX, 1 }, + { "-int index", F_NEG_INT_INDEX, 1 }, + { "apply and pop", F_APPLY_AND_POP, 1 }, + { "2 locals", F_2_LOCALS, 1 }, + { "byte", F_BYTE, 1 },   };      struct instr instrs[F_MAX_INSTR - F_OFFSET];
292:    {    if(instr_names[i].token >= F_MAX_INSTR)    fatal("Error in instr_names[%u]\n\n",i); +  +  if(instrs[instr_names[i].token - F_OFFSET].name) +  fatal("Duplicate name for %s\n",instr_names[i].word); +     instrs[instr_names[i].token - F_OFFSET].name = instr_names[i].word; -  +  instrs[instr_names[i].token - F_OFFSET].hasarg=instr_names[i].hasarg;    }       reswords=create_hash_table();