1*a1bf3f78SToomas Soome #include "ficl.h" 2*a1bf3f78SToomas Soome 3*a1bf3f78SToomas Soome /* 4*a1bf3f78SToomas Soome * w o r d I s I m m e d i a t e 5*a1bf3f78SToomas Soome */ 6*a1bf3f78SToomas Soome int 7*a1bf3f78SToomas Soome ficlWordIsImmediate(ficlWord *word) 8*a1bf3f78SToomas Soome { 9*a1bf3f78SToomas Soome return ((word != NULL) && (word->flags & FICL_WORD_IMMEDIATE)); 10*a1bf3f78SToomas Soome } 11*a1bf3f78SToomas Soome 12*a1bf3f78SToomas Soome /* 13*a1bf3f78SToomas Soome * w o r d I s C o m p i l e O n l y 14*a1bf3f78SToomas Soome */ 15*a1bf3f78SToomas Soome int 16*a1bf3f78SToomas Soome ficlWordIsCompileOnly(ficlWord *word) 17*a1bf3f78SToomas Soome { 18*a1bf3f78SToomas Soome return ((word != NULL) && (word->flags & FICL_WORD_COMPILE_ONLY)); 19*a1bf3f78SToomas Soome } 20*a1bf3f78SToomas Soome 21*a1bf3f78SToomas Soome /* 22*a1bf3f78SToomas Soome * f i c l W o r d C l a s s i f y 23*a1bf3f78SToomas Soome * This public function helps to classify word types for SEE 24*a1bf3f78SToomas Soome * and the debugger in tools.c. Given an pointer to a word, it returns 25*a1bf3f78SToomas Soome * a member of WOR 26*a1bf3f78SToomas Soome */ 27*a1bf3f78SToomas Soome ficlWordKind 28*a1bf3f78SToomas Soome ficlWordClassify(ficlWord *word) 29*a1bf3f78SToomas Soome { 30*a1bf3f78SToomas Soome ficlPrimitive code; 31*a1bf3f78SToomas Soome ficlInstruction i; 32*a1bf3f78SToomas Soome ficlWordKind iType; 33*a1bf3f78SToomas Soome 34*a1bf3f78SToomas Soome if ((((ficlInstruction)word) > ficlInstructionInvalid) && 35*a1bf3f78SToomas Soome (((ficlInstruction)word) < ficlInstructionLast)) { 36*a1bf3f78SToomas Soome i = (ficlInstruction)word; 37*a1bf3f78SToomas Soome iType = FICL_WORDKIND_INSTRUCTION; 38*a1bf3f78SToomas Soome goto IS_INSTRUCTION; 39*a1bf3f78SToomas Soome } 40*a1bf3f78SToomas Soome 41*a1bf3f78SToomas Soome code = word->code; 42*a1bf3f78SToomas Soome 43*a1bf3f78SToomas Soome if ((((ficlInstruction)code) > ficlInstructionInvalid) && 44*a1bf3f78SToomas Soome (((ficlInstruction)code) < ficlInstructionLast)) { 45*a1bf3f78SToomas Soome i = (ficlInstruction)code; 46*a1bf3f78SToomas Soome iType = FICL_WORDKIND_INSTRUCTION_WORD; 47*a1bf3f78SToomas Soome goto IS_INSTRUCTION; 48*a1bf3f78SToomas Soome } 49*a1bf3f78SToomas Soome 50*a1bf3f78SToomas Soome return (FICL_WORDKIND_PRIMITIVE); 51*a1bf3f78SToomas Soome 52*a1bf3f78SToomas Soome IS_INSTRUCTION: 53*a1bf3f78SToomas Soome 54*a1bf3f78SToomas Soome switch (i) { 55*a1bf3f78SToomas Soome case ficlInstructionConstantParen: 56*a1bf3f78SToomas Soome #if FICL_WANT_FLOAT 57*a1bf3f78SToomas Soome case ficlInstructionFConstantParen: 58*a1bf3f78SToomas Soome #endif /* FICL_WANT_FLOAT */ 59*a1bf3f78SToomas Soome return (FICL_WORDKIND_CONSTANT); 60*a1bf3f78SToomas Soome 61*a1bf3f78SToomas Soome case ficlInstruction2ConstantParen: 62*a1bf3f78SToomas Soome #if FICL_WANT_FLOAT 63*a1bf3f78SToomas Soome case ficlInstructionF2ConstantParen: 64*a1bf3f78SToomas Soome #endif /* FICL_WANT_FLOAT */ 65*a1bf3f78SToomas Soome return (FICL_WORDKIND_2CONSTANT); 66*a1bf3f78SToomas Soome 67*a1bf3f78SToomas Soome #if FICL_WANT_LOCALS 68*a1bf3f78SToomas Soome case ficlInstructionToLocalParen: 69*a1bf3f78SToomas Soome case ficlInstructionTo2LocalParen: 70*a1bf3f78SToomas Soome #if FICL_WANT_FLOAT 71*a1bf3f78SToomas Soome case ficlInstructionToFLocalParen: 72*a1bf3f78SToomas Soome case ficlInstructionToF2LocalParen: 73*a1bf3f78SToomas Soome #endif /* FICL_WANT_FLOAT */ 74*a1bf3f78SToomas Soome return (FICL_WORDKIND_INSTRUCTION_WITH_ARGUMENT); 75*a1bf3f78SToomas Soome #endif /* FICL_WANT_LOCALS */ 76*a1bf3f78SToomas Soome 77*a1bf3f78SToomas Soome #if FICL_WANT_USER 78*a1bf3f78SToomas Soome case ficlInstructionUserParen: 79*a1bf3f78SToomas Soome return (FICL_WORDKIND_USER); 80*a1bf3f78SToomas Soome #endif 81*a1bf3f78SToomas Soome 82*a1bf3f78SToomas Soome case ficlInstruction2LiteralParen: 83*a1bf3f78SToomas Soome return (FICL_WORDKIND_2LITERAL); 84*a1bf3f78SToomas Soome 85*a1bf3f78SToomas Soome #if FICL_WANT_FLOAT 86*a1bf3f78SToomas Soome case ficlInstructionFLiteralParen: 87*a1bf3f78SToomas Soome return (FICL_WORDKIND_FLITERAL); 88*a1bf3f78SToomas Soome #endif 89*a1bf3f78SToomas Soome case ficlInstructionCreateParen: 90*a1bf3f78SToomas Soome return (FICL_WORDKIND_CREATE); 91*a1bf3f78SToomas Soome 92*a1bf3f78SToomas Soome case ficlInstructionCStringLiteralParen: 93*a1bf3f78SToomas Soome return (FICL_WORDKIND_CSTRING_LITERAL); 94*a1bf3f78SToomas Soome 95*a1bf3f78SToomas Soome case ficlInstructionStringLiteralParen: 96*a1bf3f78SToomas Soome return (FICL_WORDKIND_STRING_LITERAL); 97*a1bf3f78SToomas Soome 98*a1bf3f78SToomas Soome case ficlInstructionColonParen: 99*a1bf3f78SToomas Soome return (FICL_WORDKIND_COLON); 100*a1bf3f78SToomas Soome 101*a1bf3f78SToomas Soome case ficlInstructionDoDoes: 102*a1bf3f78SToomas Soome return (FICL_WORDKIND_DOES); 103*a1bf3f78SToomas Soome 104*a1bf3f78SToomas Soome case ficlInstructionDoParen: 105*a1bf3f78SToomas Soome return (FICL_WORDKIND_DO); 106*a1bf3f78SToomas Soome 107*a1bf3f78SToomas Soome case ficlInstructionQDoParen: 108*a1bf3f78SToomas Soome return (FICL_WORDKIND_QDO); 109*a1bf3f78SToomas Soome 110*a1bf3f78SToomas Soome case ficlInstructionVariableParen: 111*a1bf3f78SToomas Soome return (FICL_WORDKIND_VARIABLE); 112*a1bf3f78SToomas Soome 113*a1bf3f78SToomas Soome case ficlInstructionBranchParenWithCheck: 114*a1bf3f78SToomas Soome case ficlInstructionBranchParen: 115*a1bf3f78SToomas Soome return (FICL_WORDKIND_BRANCH); 116*a1bf3f78SToomas Soome 117*a1bf3f78SToomas Soome case ficlInstructionBranch0ParenWithCheck: 118*a1bf3f78SToomas Soome case ficlInstructionBranch0Paren: 119*a1bf3f78SToomas Soome return (FICL_WORDKIND_BRANCH0); 120*a1bf3f78SToomas Soome 121*a1bf3f78SToomas Soome case ficlInstructionLiteralParen: 122*a1bf3f78SToomas Soome return (FICL_WORDKIND_LITERAL); 123*a1bf3f78SToomas Soome 124*a1bf3f78SToomas Soome case ficlInstructionLoopParen: 125*a1bf3f78SToomas Soome return (FICL_WORDKIND_LOOP); 126*a1bf3f78SToomas Soome 127*a1bf3f78SToomas Soome case ficlInstructionOfParen: 128*a1bf3f78SToomas Soome return (FICL_WORDKIND_OF); 129*a1bf3f78SToomas Soome 130*a1bf3f78SToomas Soome case ficlInstructionPlusLoopParen: 131*a1bf3f78SToomas Soome return (FICL_WORDKIND_PLOOP); 132*a1bf3f78SToomas Soome 133*a1bf3f78SToomas Soome default: 134*a1bf3f78SToomas Soome return (iType); 135*a1bf3f78SToomas Soome } 136*a1bf3f78SToomas Soome } 137