[ANN][VM][SF] my Unix patches integrated into SF layout

Lex Spoon lex at cc.gatech.edu
Tue Jan 1 23:13:50 UTC 2002


> 
> But it doesn't work for me (yet).

Drats.  Okay, let's see....



> - First, I expected to have to run the copied version of configure in
> the build directory as with the current SF tree; but ok, you documented
> that one should use the one in "platforms/unix/misc"
> - Then, I see that all the *.c files are compiled from the "platforms"
> hierarchy, and not in the copied hierarchy under the build dir; here it
> really doesn't make any sense to copy everything first

It's just as easy to use the files right from platforms/unix/misc, as to
remember to copy them over.  Also, while *developing* these files, it is
very nice to be able to edit them and the re-run the compile, without
having to also copy them again.  So, I left them there....
 



> CASE(0:)

Drats -- different awk's seem to do handle substr() differently -- just
try the output of this under gawk versus mawk:

	gawk 'BEGIN {print substr("12:",0,2); }'


Here's a gnuify that uses a simpler and hopefully more portable trick
(why didn't this come to mind before?!): do (($NF) + 0) to read off the
initial integer of a sting.  Ugly?  Yes, but it's very near to the heart
of awkdom -- if it doesn't work, I'm not sure it can really be called
"awk".  "ack", "ptoey", "gross", "spglark".... but not awk.

Could you give it another try?  Below is a new file, and I've updated
sha.tgz on the Swiki.


-Lex

====
#!/bin/awk -f
# 
#   Copyright (C) 1996 1997 1998 1999 2000 2001 Ian Piumarta and individual
#      authors/contributors listed elsewhere in this file.
#   All rights reserved.
#   
#   This file is part of Unix Squeak.
# 
#   This file is distributed in the hope that it will be useful, but WITHOUT
#   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#   FITNESS FOR A PARTICULAR PURPOSE.
#   
#   You may use and/or distribute this file ONLY as part of Squeak, under
#   the terms of the Squeak License as described in `LICENSE' in the base of
#   this distribution, subject to the following restrictions:
# 
#   1. The origin of this software must not be misrepresented; you must not
#      claim that you wrote the original software.  If you use this software
#      in a product, an acknowledgment to the original author(s) (and any
#      other contributors mentioned herein) in the product documentation
#      would be appreciated but is not required.
# 
#   2. This notice may not be removed or altered in any source distribution.
# 
#   Using or modifying this file for use in any context other than Squeak
#   changes these copyright conditions.  Read the file `COPYING' in the base
#   of the distribution before proceeding with any such use.
# 
#   You are STRONGLY DISCOURAGED from distributing a modified version of
#   this file under its original name without permission.  If you must
#   change it, rename it first.

# Author: Ian.Piumarta at INRIA.Fr
#
# Last edited: 2000-10-18 20:30:52 by piumarta on emilia.rd.wdi.disney.com

# Rewrite the interpreter source in $1 to use GNU C extensions, writing the
# modified file to stdout.  Author: Ian.Piumarta at inria.fr

# 2001-8-1 Updated by Lex Spoon to (hopefully) work on all awk's
# 2002-1-1 Updated by Lex Spoon again....

BEGIN {
  print "/* This file has been post-processed for GNU C */\n\n\n";
#  print "copying first section of file" > "/dev/stderr";
  stage= 0;
}

/#include "sq.h"/ {
  print "#include \"sqGnu.h\"\n";
  next;
}

# An inlining comment means the interpreter was not inlined

/inline: true/ {
#  print NR, $0 > "/dev/stderr";
#  print "" > "/dev/stderr";
#  print "*** interpreter was not inlined: bailing out! ***" > "/dev/stderr";
#  print "" > "/dev/stderr";
  stage= 1000;
}



(stage == 0) && /^int interpret\(void\) \{/ {
#  print "interpret: adding static register assignments" > "/dev/stderr";
  stage= 1;
  print;
  next;
}

(stage == 1) && /^    char\* localIP;/ {
  print "    register char* localIP IP_REG;";
  next;
}

(stage == 1) && /^    char\* localSP;/ {
  print "    register char* localSP SP_REG;";
  next;
}

(stage == 1) && /^    int currentBytecode;/ {
  print "    register int currentBytecode CB_REG;";
  next;
}

(stage == 1) && /^$/ {
#  print "interpret: adding bytecode dispatch table" > "/dev/stderr";
  print "    JUMP_TABLE;\n";
#  print "interpret: rewriting case labels and outer breaks" > "/dev/stderr";
  stage= 2;
  FS=" ";
  next;
}

(stage == 2) && /^		case / {
  print "		CASE(" (($NF) + 0) ")";
  next;
}

(stage == 2) && /^			break;/ {
  print "			BREAK;";
  next;
}

(stage == 2) && /^\}/ {
  stage= 3;
  print;
  next;
}

(stage == 3) && /^int primitiveResponse\(/ {
  print;
#  print "primitiveResponse: adding primitive dispatch table" > "/dev/stderr";
  print "    PRIM_TABLE;\n";
#  print "primitiveResponse: rewriting case labels" > "/dev/stderr";
  stage= 4;
  FS=" ";
  next;
}


(stage == 4) && /^	switch \(primitiveIndex\) {/ {
#  print "primitiveResponse: adding primitive dispatch" > "/dev/stderr";
  print "	PRIM_DISPATCH;";
  print;
  next;
}

(stage == 4) && /^	case / {
  print "		CASE(" (($NF) + 0) ")";
  next;
}

(stage == 4) && /^\}/ {
#  print "copying last section of file" > "/dev/stderr";
  stage= 5;
  FS=" ";
  print;
  next;
}

# default
{
  print;
  next;
}




More information about the Squeak-dev mailing list