Inform - Support - Source

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing parserm.h

PrintAnything (lines 5968-6024)

5968  ! This somewhat obfuscated function will print anything.
5969  ! It handles strings, functions (with optional arguments), objects,
5970  ! object properties (with optional arguments), and dictionary words.
5971  ! It does *not* handle plain integers, but you can use
5972  ! DecimalNumber or EnglishNumber to handle that case.
5973  !
5974  ! Calling:                           Is equivalent to:
5975  ! -------                            ----------------
5976  ! PrintAnything()                    
5977  ! PrintAnything(0)                   
5978  ! PrintAnything("string");           print (string) "string";
5979  ! PrintAnything('word')              print (address) 'word';
5980  ! PrintAnything(obj)                 print (name) obj;
5981  ! PrintAnything(obj, prop)           obj.prop();
5982  ! PrintAnything(obj, prop, args...)  obj.prop(args...);
5983  ! PrintAnything(func)                func();
5984  ! PrintAnything(func, args...)       func(args...);
5985   
5986  [ PrintAnything _vararg_count obj mclass;
5987      if (_vararg_count == 0) return;
5988      @copy sp obj;
5989      _vararg_count--;
5990      if (obj == 0) return;
5991   
5992      if (obj->0 == $60) {
5993          ! Dictionary word. Metaclass() can't catch this case, so we do
5994          ! it manually.
5995          print (address) obj;
5996          return;
5997      }
5998   
5999      mclass = metaclass(obj);
6000      switch (mclass) {
6001        nothing:
6002          return;
6003        String:
6004          print (string) obj;
6005          return;
6006        Routine:
6007          ! Call the function with all the arguments which are already
6008          ! on the stack.
6009          @call obj _vararg_count 0;
6010          return;
6011        Object:
6012          if (_vararg_count == 0) {
6013              print (name) obj;
6014          }
6015          else {
6016              ! Push the object back onto the stack, and call the
6017              ! veneer routine that handles obj.prop() calls.
6018              @copy obj sp;
6019              _vararg_count++;
6020              @call CA__Pr _vararg_count 0;
6021          }
6022          return;
6023      }
6024  ];


Last updated 27 February 2004. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Graham Nelson assisted by C Knight.