Class RTS_UTIL

java.lang.Object
simula.runtime.RTS_UTIL

public final class RTS_UTIL extends Object

Utility class containing a lot of common stuff.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
  • Field Details

    • console

      static RTS_ConsolePanel console
      The runtime console. May be null
    • progamIdent

      static String progamIdent
      The program ident.
    • currentModid

      static String currentModid
      The current module ident.
    • currentSimLine

      static int currentSimLine
      The current simula source line number.
    • numberOfEditOverflows

      static int numberOfEditOverflows
      Number of edit overflows.
    • NOTEXT

      public static final RTS_TXT NOTEXT
      Utility constant NOTEXT
  • Constructor Details

    • RTS_UTIL

      private RTS_UTIL()
      Default constructor.
  • Method Details

    • _ASGTXT

      public static RTS_TXT _ASGTXT(RTS_TXT T, RTS_TXT U)
      Text value assignment.
      Parameters:
      T - the from text
      U - the target text
      Returns:
      the resulting text
    • _ASGSTR

      public static RTS_TXT _ASGSTR(RTS_TXT T, String s)
      Text value assignment from String.
      Parameters:
      T - the from text
      s - the target text
      Returns:
      the resulting text
    • _TXTREL_LT

      public static boolean _TXTREL_LT(RTS_TXT left, RTS_TXT right)
      Text value relation - LT
      Parameters:
      left - left hand side
      right - right hand side
      Returns:
      true if relation holds
    • _TXTREL_EQ

      public static boolean _TXTREL_EQ(RTS_TXT left, RTS_TXT right)
      Text value relation - EQ
      Parameters:
      left - left hand side
      right - right hand side
      Returns:
      true if relation holds
    • _TXTREL_LE

      public static boolean _TXTREL_LE(RTS_TXT left, RTS_TXT right)
      Text value relation - LE
      Parameters:
      left - left hand side
      right - right hand side
      Returns:
      true if relation holds
    • _TXTREL_GT

      public static boolean _TXTREL_GT(RTS_TXT left, RTS_TXT right)
      Text value relation - GT
      Parameters:
      left - left hand side
      right - right hand side
      Returns:
      true if relation holds
    • _TXTREL_NE

      public static boolean _TXTREL_NE(RTS_TXT left, RTS_TXT right)
      Text value relation - NE
      Parameters:
      left - left hand side
      right - right hand side
      Returns:
      true if relation holds
    • _TXTREL_GE

      public static boolean _TXTREL_GE(RTS_TXT left, RTS_TXT right)
      Text value relation - GE
      Parameters:
      left - left hand side
      right - right hand side
      Returns:
      true if relation holds
    • TXTREL

      private static boolean TXTREL(RTS_TXT left, RTS_TXT right, int code)
      Text value relation
      Parameters:
      left - left hand side
      right - right hand side
      code - relational code
      Returns:
      true if relation holds
    • TRF_EQ

      public static boolean TRF_EQ(RTS_TXT left, RTS_TXT right)
      Text reference equal relation
      Parameters:
      left - left hand side
      right - right hand side
      Returns:
      true if relation holds
    • TRF_NE

      public static boolean TRF_NE(RTS_TXT left, RTS_TXT right)
      Text reference not equal relation
      Parameters:
      left - left hand side
      right - right hand side
      Returns:
      true if relation holds
    • _IADD

      public static int _IADD(int x, int y)
      Integer Addition: x + y
      Parameters:
      x - argument x
      y - argument y
      Returns:
      x + y
    • _ISUB

      public static int _ISUB(int x, int y)
      Integer Subtraction: x - y
      Parameters:
      x - argument x
      y - argument y
      Returns:
      x - y
    • _IMUL

      public static int _IMUL(int x, int y)
      Integer Multiplication: x * y
      Parameters:
      x - argument x
      y - argument y
      Returns:
      x * y
    • _IPOW

      public static int _IPOW(int b, int x)
      Integer Power: b ** x
      Parameters:
      b - argument b
      x - argument x
      Returns:
      b ** x
    • _IS

      public static boolean _IS(Object obj, Class<?> cls)

      Object relation: IS.

            simple-object-expression is class-identifier
      
      Parameters:
      obj - object reference
      cls - class reference
      Returns:
      true: relation holds
    • isign

      public static int isign(int e)

      Standard Procedure sign.

      integer procedure sign(e);    e;
          sign := if e > 0 then  1
             else if e < 0 then -1 else 0;
      

      The result is zero if the parameter is zero, one if the parameter is positive, and minus one otherwise.

      Parameters:
      e - the argument e
      Returns:
      resulting sign code
    • fsign

      public static float fsign(float e)
      Standard Procedure sign.
      Parameters:
      e - the argument e
      Returns:
      resulting sign code
    • dsign

      public static double dsign(double e)
      Standard Procedure sign.
      Parameters:
      e - the argument e
      Returns:
      resulting sign code
    • treatException

      public static void treatException(Throwable e, RTS_RTObject obj)
      Treat Exception
      Parameters:
      e - the Throwable Object
      obj - the RTObject which object that received the exception
    • callExceptionHandler

      private static void callExceptionHandler(String msg)
      Utility: Treat Runtime error
      Parameters:
      msg - the message
    • getErrorMessage

      public static String getErrorMessage(Throwable e)
      Utility to convert a Throwable message to Simula message.
      Parameters:
      e - a Throwable
      Returns:
      converted message
    • endProgram

      static void endProgram(int exitValue)
      End of Simula program execution.
      Parameters:
      exitValue - the exit value
    • BPRG

      public static void BPRG(String ident, String[] args)
      The begin program routine (BPRG) is the runtime system initialization routine. It will initiate the global data in the runtime system.
      Parameters:
      ident - the program identifier
      args - the arguments
    • RUN_STM

      public static void RUN_STM(RTS_RTObject usr)
      Run users statements
      Parameters:
      usr - user program
    • help

      private static void help()
      Print synopsis of standard options
    • setRuntimeOptions

      public static void setRuntimeOptions(String[] args)
      Set runtime options.
      Parameters:
      args - argument array
    • popUpError

      static void popUpError(String msg)
      Popup an error message box.
      Parameters:
      msg - the error message
    • optionDialog

      static int optionDialog(Object msg, String title, int optionType, int messageType, String... option)
      Brings up an option dialog.
      Parameters:
      msg - the message to display
      title - the title string for the dialog
      optionType - an integer designating the options available on the dialog
      messageType - an integer designating the kind of message this is
      option - an array of objects indicating the possible choices the user can make
      Returns:
      an integer indicating the option chosen by the user, or CLOSED_OPTION if the user closed the dialog
    • listRuntimeOptions

      static void listRuntimeOptions()
      List runtime options.
    • println

      static void println(String msg)
      Print a line on the runtime console if present, otherwise on System.out
      Parameters:
      msg - the message to print
    • printError

      static void printError(String msg)
      Print an error on the runtime console if present, otherwise on System.out
      Parameters:
      msg - the message to print
    • printWarning

      static void printWarning(String msg)
      Print a warning message on the runtime console if present, otherwise on System.out
      Parameters:
      msg - the message to print
    • ensureOpenRuntimeConsole

      static void ensureOpenRuntimeConsole()
      Open Simula Runtime Console.
    • TRACE

      static void TRACE(String msg)
      TRACE Utility.
      Parameters:
      msg - a trace message
    • IERR

      static void IERR(String msg)
      Utility: Internal error.
      Parameters:
      msg - an error message
    • getJavaID

      static String getJavaID()
      Returns System property "java.vm.specification.version"
      Returns:
      System property "java.vm.specification.version"
    • _SNAPSHOT

      public static void _SNAPSHOT(int sequ, String msg)
      Debug utility method to print a snapshot in the generated code.
      Parameters:
      sequ - a sequence number
      msg - a message
    • _SNAPSHOT

      public static void _SNAPSHOT(Object TOS, int sequ, String msg)
      Debug utility method to print a snapshot in the generated code.
      Parameters:
      TOS - top of operand stack
      sequ - a sequence number
      msg - a message
    • printStaticChain

      static void printStaticChain()
      Print static chain starting with the current instance.
    • printStaticChain

      static void printStaticChain(RTS_RTObject ins)
      Print static chain starting with 'ins'
      Parameters:
      ins - argument
    • printSimulaStackTrace

      static void printSimulaStackTrace(int start)
      Utility: Print Simula stack trace.
      Parameters:
      start - start index in Java stackTrace
    • printSimulaStackTrace

      static void printSimulaStackTrace(Throwable e, int start)
      Utility: Print Simula stack trace.
      Parameters:
      e - a Throwable
      start - start index in Java stackTrace
    • printSimulaStackTrace

      private static void printSimulaStackTrace(StackTraceElement[] stackTraceElement, int start)
      Utility: Print Simula StackTrace.
      Parameters:
      stackTraceElement - Java stackTrace
      start - start index in Java stackTrace
    • printSimulaLineInfo

      private static boolean printSimulaLineInfo(StackTraceElement elt, String lead)
      Utility: Print SimulaLineInfo
      Parameters:
      elt - a StackTraceElement
      lead - the keading string
      Returns:
      the resulting line info
    • printThreadList

      static void printThreadList()
      Print Thread list.
    • printThreadList

      static void printThreadList(boolean withStackTrace)
      Print Thread list.
      Parameters:
      withStackTrace - argument
    • _LINE

      public static void _LINE(String modid, int simLine)
      Utility: Set current modid and Simula source line number.
      Parameters:
      modid - new current modid
      simLine - new Simula source line number