// IsConstOrVar - Checkes whether a specified word is a constant or a variable // Input: Atom - the name of the atom // Output: Returns true if the specified word is a constant or a variable private bool IsConstOrVar(string Atom) { bool bConstOrVar = false; // Search constant name space for (int i = 0; i < GlobalConstants.Count; i++) { ForthConstant fc = (ForthConstant)GlobalConstants[i]; if (fc.Name.ToUpper() == Atom.ToUpper()) { bConstOrVar = true; } } // Search variable name space for (int i = 0; i < GlobalVariables.Count; i++) { ForthVariable fv = (ForthVariable)GlobalVariables[i]; if (fv.Name.ToUpper() == Atom.ToUpper()) { bConstOrVar = true; } } return(bConstOrVar); }
private void DisplayMapInformation() { int i; Console.WriteLine("--- Map Information -------------------------------------\n\r"); Console.WriteLine("* Global constants:"); // Display global constants for (i = 0; i < GlobalConstants.Count; i++) { ForthConstant fc = (ForthConstant)GlobalConstants[i]; if (fc.Value.GetType() != typeof(string)) { Console.WriteLine("{0} = {1}", fc.Name, fc.Value); } else { Console.WriteLine("{0} = \"{1}\"", fc.Name, fc.Value); } } // Display global variables Console.WriteLine("\n* Global variables:"); for (i = 0; i < GlobalVariables.Count; i++) { ForthVariable fv = (ForthVariable)GlobalVariables[i]; Console.WriteLine("{0} = (Addr:{1}, Size:{2})", fv.Name, fv.Address, fv.Size); } // Display local variables Console.WriteLine("\n* Local variables:"); for (i = 0; i < LocalVariables.Count; i++) { ForthLocalVariable flv = (ForthLocalVariable)LocalVariables[i]; Console.WriteLine("{0} = (Addr:{1}, Word:{2})", flv.Name, flv.Address, flv.WordName); } // Display external words Console.WriteLine("\n* External words:"); for (i = 0; i < ExternalWords.Count; i++) { ExternalWord ew = (ExternalWord)ExternalWords[i]; Console.WriteLine("{0} = (Library:{1}, Class:{2}, Method:{3})", ew.Name, ew.Library, ew.Class, ew.Method); } Console.WriteLine(); }
// GetConstIntValue - Retrieves the value of an integer constant (if found) // Input: ConstName - the name of the constant // Output: ConstValue - The integer value of the constant private bool GetConstIntValue(string ConstName, out int ConstValue) { bool ConstFound = false; ConstValue = 0; IEnumerator ConstEnum = GlobalConstants.GetEnumerator(); while (ConstEnum.MoveNext()) { ForthConstant fc = (ForthConstant)ConstEnum.Current; if ((fc.Name.ToLower() == ConstName.ToLower()) && (fc.Value.GetType() == typeof(int))) { ConstValue = (int)fc.Value; ConstFound = true; } } return(ConstFound); }