You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(116) |
May
(220) |
Jun
(52) |
Jul
(30) |
Aug
(35) |
Sep
(24) |
Oct
(49) |
Nov
(44) |
Dec
(70) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(21) |
Feb
(30) |
Mar
(9) |
Apr
(44) |
May
(2) |
Jun
|
Jul
(10) |
Aug
(20) |
Sep
(25) |
Oct
(12) |
Nov
(16) |
Dec
(4) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(25) |
Aug
|
Sep
|
Oct
|
Nov
(26) |
Dec
(10) |
2006 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(33) |
2007 |
Jan
(4) |
Feb
(57) |
Mar
(17) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ma...@us...> - 2003-11-13 01:40:40
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv27141/src/org/jrman/render Modified Files: SimpleMicropolygon.java Log Message: Small speed improvement. Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SimpleMicropolygon.java 6 Nov 2003 01:38:39 -0000 1.12 --- SimpleMicropolygon.java 13 Nov 2003 01:40:34 -0000 1.13 *************** *** 198,206 **** private void addPointToBounds(float x, float y, float z) { ! minX = Math.min(minX, x); ! maxX = Math.max(maxX, x); ! minY = Math.min(minY, y); ! maxY = Math.max(maxY, y); ! minZ = Math.min(minZ, z); } --- 198,206 ---- private void addPointToBounds(float x, float y, float z) { ! minX = Calc.min(minX, x); ! maxX = Calc.max(maxX, x); ! minY = Calc.min(minY, y); ! maxY = Calc.max(maxY, y); ! minZ = Calc.min(minZ, z); } *************** *** 231,234 **** --- 231,239 ---- public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); + if (point.x < minX || point.x > maxX || point.y < minY || point.y > maxY) + return; + float z = nxOverZ * (ax - point.x) + nyOverZ * (ay - point.y) + az; + if (z < minZ) + return; if ((ay - by) * (point.x - ax) + (bx - ax) * (point.y - ay) > 0f) return; *************** *** 237,241 **** if ((cy - ay) * (point.x - cx) + (ax - cx) * (point.y - cy) > 0f) return; - float z = nxOverZ * (ax - point.x) + nyOverZ * (ay - point.y) + az; sp.addSample( colorRed, --- 242,245 ---- |
Update of /cvsroot/jrman/drafts/src/org/jrman/sl In directory sc8-pr-cvs1:/tmp/cvs-serv7183/src/org/jrman/sl Added Files: Tuple3fGridValue.java FloatValue.java FloatGridValue.java Value.java Tuple3fValue.java Log Message: Started working on shading language VM interpreter. --- NEW FILE: Tuple3fGridValue.java --- /* Tuple3fGridValue.java Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.sl; import org.jrman.grid.Point3fGrid; import org.jrman.grid.Tuple3fGrid; public class Tuple3fGridValue extends Value { private Tuple3fGrid value; public static Tuple3fGridValue cast(FloatGridValue fgv) { Point3fGrid p3fg = Point3fGrid.getInstance(); p3fg.set(fgv.getValue()); return new Tuple3fGridValue(p3fg); } public Tuple3fGridValue(Tuple3fGrid value) { this.value = value; } public Tuple3fGrid getValue() { return value; } } --- NEW FILE: FloatValue.java --- /* FloatValue.java Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.sl; import org.jrman.grid.BooleanGrid; public class FloatValue extends Value { private float value; public FloatValue(float value) { this.value = value; } public float getValue() { return value; } public Value add(Value other, BooleanGrid cond) { if (other instanceof FloatValue) return new FloatValue(value + ((FloatValue) other).value); else return other.reverseAdd(this, cond); } public Value sub(Value other, BooleanGrid cond) { if (other instanceof FloatValue) return new FloatValue(value - ((FloatValue) other).value); return other.reverseSub(this, cond); } public Value mul(Value other, BooleanGrid cond) { if (other instanceof FloatValue) return new FloatValue(value * ((FloatValue) other).value); return other.reverseMul(this, cond); } public Value div(Value other, BooleanGrid cond) { if (other instanceof FloatValue) return new FloatValue(value / ((FloatValue) other).value); return other.reverseDiv(this, cond); } public Value negate(BooleanGrid cond) { return new FloatValue(-value); } } --- NEW FILE: FloatGridValue.java --- /* FloatGridValue.java Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.sl; import org.jrman.grid.BooleanGrid; import org.jrman.grid.FloatGrid; public class FloatGridValue extends Value { private FloatGrid value; public FloatGridValue(FloatGrid value) { this.value = value; } public FloatGrid getValue() { return value; } public Value add(Value other, BooleanGrid cond) { if (other instanceof FloatValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.add(value, ((FloatValue) other).getValue(), cond); else fg.add(value, ((FloatValue) other).getValue()); return new FloatGridValue(fg); } if (other instanceof FloatGridValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.add(value, ((FloatGridValue) other).getValue(), cond); else fg.add(value, ((FloatGridValue) other).getValue()); return new FloatGridValue(fg); } return other.reverseAdd(this, cond); } public Value reverseAdd(Value other, BooleanGrid cond) { if (other instanceof FloatValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.add(value, ((FloatValue) other).getValue(), cond); else fg.add(value, ((FloatValue) other).getValue()); return new FloatGridValue(fg); } throw new UnsupportedOperationException("reverseAdd: " + other.getClass()); } public Value sub(Value other, BooleanGrid cond) { if (other instanceof FloatValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.sub(value, ((FloatValue) other).getValue(), cond); else fg.sub(value, ((FloatValue) other).getValue()); return new FloatGridValue(fg); } if (other instanceof FloatGridValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.sub(value, ((FloatGridValue) other).getValue(), cond); else fg.sub(value, ((FloatGridValue) other).getValue()); return new FloatGridValue(fg); } return other.reverseSub(this, cond); } public Value reverseSub(Value other, BooleanGrid cond) { if (other instanceof FloatValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.sub(((FloatValue) other).getValue(), value, cond); else fg.sub(((FloatValue) other).getValue(), value); return new FloatGridValue(fg); } throw new UnsupportedOperationException("reverseSub: " + other.getClass()); } public Value mul(Value other, BooleanGrid cond) { if (other instanceof FloatValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.mul(value, ((FloatValue) other).getValue(), cond); else fg.mul(value, ((FloatValue) other).getValue()); return new FloatGridValue(fg); } if (other instanceof FloatGridValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.mul(value, ((FloatGridValue) other).getValue(), cond); else fg.mul(value, ((FloatGridValue) other).getValue()); return new FloatGridValue(fg); } return other.reverseMul(this, cond); } public Value reverseMul(Value other, BooleanGrid cond) { if (other instanceof FloatValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.mul(value, ((FloatValue) other).getValue(), cond); else fg.mul(value, ((FloatValue) other).getValue()); return new FloatGridValue(fg); } throw new UnsupportedOperationException("reverseMul: " + other.getClass()); } public Value div(Value other, BooleanGrid cond) { if (other instanceof FloatValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.div(value, ((FloatValue) other).getValue(), cond); else fg.div(value, ((FloatValue) other).getValue()); return new FloatGridValue(fg); } if (other instanceof FloatGridValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.div(value, ((FloatGridValue) other).getValue(), cond); else fg.div(value, ((FloatGridValue) other).getValue()); return new FloatGridValue(fg); } return other.reverseDiv(this, cond); } public Value reverseDiv(Value other, BooleanGrid cond) { if (other instanceof FloatValue) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.div(((FloatValue) other).getValue(), value, cond); else fg.div(((FloatValue) other).getValue(), value); return new FloatGridValue(fg); } throw new UnsupportedOperationException("reverseDiv: " + other.getClass()); } public Value negate(BooleanGrid cond) { FloatGrid fg = FloatGrid.getInstance(); if (cond != null) fg.negate(value, cond); else fg.negate(value); return new FloatGridValue(fg); } } --- NEW FILE: Value.java --- /* Value.java Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.sl; import org.jrman.grid.BooleanGrid; public abstract class Value { public Value add(Value other, BooleanGrid cond) { throw new UnsupportedOperationException("add"); } public Value reverseAdd(Value other, BooleanGrid cond) { throw new UnsupportedOperationException("reverseAdd"); } public Value sub(Value other, BooleanGrid cond) { throw new UnsupportedOperationException("sub"); } public Value reverseSub(Value other, BooleanGrid cond) { throw new UnsupportedOperationException("reverseSub"); } public Value mul(Value other, BooleanGrid cond) { throw new UnsupportedOperationException("mul"); } public Value reverseMul(Value other, BooleanGrid cond) { throw new UnsupportedOperationException("reverseMul"); } public Value div(Value other, BooleanGrid cond) { throw new UnsupportedOperationException("div"); } public Value reverseDiv(Value other, BooleanGrid cond) { throw new UnsupportedOperationException("reverseDiv"); } public Value negate(BooleanGrid cond) { throw new UnsupportedOperationException("negate"); } } --- NEW FILE: Tuple3fValue.java --- /* Tuple3fValue.java Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.sl; import javax.vecmath.Color3f; import javax.vecmath.Point3f; import javax.vecmath.Tuple3f; import javax.vecmath.Vector3f; import org.jrman.grid.BooleanGrid; public class Tuple3fValue extends Value { private Tuple3f value; private Tuple3f getCompatibleTuple() { if (value instanceof Point3f) return new Point3f(); if (value instanceof Vector3f) return new Vector3f(); return new Color3f(); } public Tuple3fValue(Tuple3f value) { this.value = value; } public Tuple3f getValue() { return value; } public Value add(Value other, BooleanGrid cond) { if (other instanceof Tuple3fValue) { Tuple3f t3f = getCompatibleTuple(); t3f.add(value, ((Tuple3fValue) other).value); return new Tuple3fValue(t3f); } if (other instanceof FloatValue) { float v = ((FloatValue) other).getValue(); Tuple3f t3f = getCompatibleTuple(); t3f.x = value.x + v; t3f.y = value.y + v; t3f.z = value.z + v; return new Tuple3fValue(t3f); } if (other instanceof FloatGridValue) { Tuple3fGridValue t3fgv = Tuple3fGridValue.cast((FloatGridValue) other); return t3fgv.reverseAdd(this, cond); } return other.reverseAdd(this, cond); } public Value reverseAdd(Value other, BooleanGrid cond) { if (other instanceof Tuple3fValue) { Tuple3f t3f = getCompatibleTuple(); t3f.add(((Tuple3fValue) other).value, value); return new Tuple3fValue(t3f); } if (other instanceof FloatValue) { float v = ((FloatValue) other).getValue(); Tuple3f t3f = getCompatibleTuple(); t3f.x = v + value.x; t3f.y = v + value.y; t3f.z = v + value.z; return new Tuple3fValue(t3f); } if (other instanceof FloatGridValue) { Tuple3fGridValue t3fgv = Tuple3fGridValue.cast((FloatGridValue) other); return t3fgv.reverseAdd(this, cond); } throw new UnsupportedOperationException("reverseAdd: " + other.getClass()); } public Value sub(Value other, BooleanGrid cond) { if (other instanceof Tuple3fValue) { Tuple3f t3f = getCompatibleTuple(); t3f.sub(value, ((Tuple3fValue) other).value); return new Tuple3fValue(t3f); } if (other instanceof FloatValue) { float v = ((FloatValue) other).getValue(); Tuple3f t3f = getCompatibleTuple(); t3f.x = value.x - v; t3f.y = value.y - v; t3f.z = value.z - v; return new Tuple3fValue(t3f); } if (other instanceof FloatGridValue) { Tuple3fGridValue t3fgv = Tuple3fGridValue.cast((FloatGridValue) other); return t3fgv.reverseSub(this, cond); } return other.reverseSub(this, cond); } public Value reverseSub(Value other, BooleanGrid cond) { if (other instanceof Tuple3fValue) { Tuple3f t3f = getCompatibleTuple(); t3f.sub(((Tuple3fValue) other).value, value); return new Tuple3fValue(t3f); } if (other instanceof FloatValue) { float v = ((FloatValue) other).getValue(); Tuple3f t3f = getCompatibleTuple(); t3f.x = v - value.x; t3f.y = v - value.y; t3f.z = v - value.z; return new Tuple3fValue(t3f); } if (other instanceof FloatGridValue) { Tuple3fGridValue t3fgv = Tuple3fGridValue.cast((FloatGridValue) other); return t3fgv.sub(this, cond); } throw new UnsupportedOperationException("reverseSub: " + other.getClass()); } public Value mul(Value other, BooleanGrid cond) { if (other instanceof Tuple3fValue) { Tuple3f t3f = getCompatibleTuple(); Tuple3f otherValue = ((Tuple3fValue) other).getValue(); t3f.x = value.x * otherValue.x; t3f.y = value.y * otherValue.y; t3f.z = value.z * otherValue.z; return new Tuple3fValue(t3f); } if (other instanceof FloatValue) { float v = ((FloatValue) other).getValue(); Tuple3f t3f = getCompatibleTuple(); t3f.x = value.x * v; t3f.y = value.y * v; t3f.z = value.z * v; return new Tuple3fValue(t3f); } if (other instanceof FloatGridValue) { Tuple3fGridValue t3fgv = Tuple3fGridValue.cast((FloatGridValue) other); return t3fgv.reverseMul(this, cond); } return other.reverseMul(this, cond); } public Value reverseMul(Value other, BooleanGrid cond) { if (other instanceof Tuple3fValue) { Tuple3f t3f = getCompatibleTuple(); Tuple3f otherValue = ((Tuple3fValue) other).getValue(); t3f.x = otherValue.x * value.x; t3f.y = otherValue.y * value.y; t3f.z = otherValue.z * value.z; return new Tuple3fValue(t3f); } if (other instanceof FloatValue) { float v = ((FloatValue) other).getValue(); Tuple3f t3f = getCompatibleTuple(); t3f.x = v * value.x; t3f.y = v * value.y; t3f.z = v * value.z; return new Tuple3fValue(t3f); } if (other instanceof FloatGridValue) { Tuple3fGridValue t3fgv = Tuple3fGridValue.cast((FloatGridValue) other); return t3fgv.reverseMul(this, cond); } throw new UnsupportedOperationException("reverseMul: " + other.getClass()); } public Value div(Value other, BooleanGrid cond) { if (other instanceof Tuple3fValue) { Tuple3f t3f = getCompatibleTuple(); Tuple3f otherValue = ((Tuple3fValue) other).getValue(); t3f.x = value.x / otherValue.x; t3f.y = value.y / otherValue.y; t3f.z = value.z / otherValue.z; return new Tuple3fValue(t3f); } if (other instanceof FloatValue) { float v = ((FloatValue) other).getValue(); Tuple3f t3f = getCompatibleTuple(); t3f.x = value.x / v; t3f.y = value.y / v; t3f.z = value.z / v; return new Tuple3fValue(t3f); } if (other instanceof FloatGridValue) { Tuple3fGridValue t3fgv = Tuple3fGridValue.cast((FloatGridValue) other); return t3fgv.reverseDiv(this, cond); } return other.reverseDiv(this, cond); } public Value reverseDiv(Value other, BooleanGrid cond) { if (other instanceof Tuple3fValue) { Tuple3f t3f = getCompatibleTuple(); Tuple3f otherValue = ((Tuple3fValue) other).getValue(); t3f.x = otherValue.x / value.x; t3f.y = otherValue.y / value.y; t3f.z = otherValue.z / value.z; return new Tuple3fValue(t3f); } if (other instanceof FloatValue) { float v = ((FloatValue) other).getValue(); Tuple3f t3f = getCompatibleTuple(); t3f.x = v / value.x; t3f.y = v / value.y; t3f.z = v / value.z; return new Tuple3fValue(t3f); } if (other instanceof FloatGridValue) { Tuple3fGridValue t3fgv = Tuple3fGridValue.cast((FloatGridValue) other); return t3fgv.div(this, cond); } throw new UnsupportedOperationException("reverseDiv: " + other.getClass()); } public Value negate(BooleanGrid cond) { Tuple3f t3f = getCompatibleTuple(); t3f.negate(value); return new Tuple3fValue(t3f); } } |
From: <ma...@us...> - 2003-11-08 17:24:30
|
Update of /cvsroot/jrman/drafts/src/org/jrman/sl In directory sc8-pr-cvs1:/tmp/cvs-serv7154/src/org/jrman/sl Log Message: Directory /cvsroot/jrman/drafts/src/org/jrman/sl added to the repository |
From: <ma...@us...> - 2003-11-06 01:38:43
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1:/tmp/cvs-serv25011/sampleData Added Files: jrm.bat Log Message: Small fixes. Micropolygon sampling tests. --- NEW FILE: jrm.bat --- @echo off set CLASSPATH=..\build;..\lib\vecmath.jar;..\src set MEMORY=384m java -server -Xprof -Xms%MEMORY% -Xmx%MEMORY% org.jrman.main.JRMan %* |
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv25011/src/org/jrman/render Modified Files: Micropolygon.java RendererHidden.java SamplePoint.java Sampler.java SimpleMicropolygon.java Log Message: Small fixes. Micropolygon sampling tests. Index: Micropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Micropolygon.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Micropolygon.java 5 Nov 2003 04:13:12 -0000 1.14 --- Micropolygon.java 6 Nov 2003 01:38:39 -0000 1.15 *************** *** 24,27 **** --- 24,28 ---- import java.io.IOException; + import org.jrman.util.Constants; public abstract class Micropolygon implements Comparable { *************** *** 29,32 **** --- 30,49 ---- public static int count; + /* + public Micropolygon next; + + public int startCol; + */ + + protected float minX = Constants.INFINITY; + + protected float maxX = -Constants.INFINITY; + + protected float minY = Constants.INFINITY; + + protected float maxY = -Constants.INFINITY; + + protected float minZ = Constants.INFINITY; + public abstract void sample(Sampler sampler); *************** *** 37,48 **** public abstract void sampleAtPoint(SamplePoint sp); ! public abstract float getMinX(); ! public abstract float getMinY(); ! public abstract float getMaxX(); ! public abstract float getMaxY(); - public abstract float getMinZ(); } --- 54,76 ---- public abstract void sampleAtPoint(SamplePoint sp); ! public final float getMaxX() { ! return maxX; ! } ! public final float getMaxY() { ! return maxY; ! } ! public final float getMinX() { ! return minX; ! } ! public final float getMinY() { ! return minY; ! } ! ! public final float getMinZ() { ! return minZ; ! } } Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** RendererHidden.java 3 Nov 2003 16:35:05 -0000 1.50 --- RendererHidden.java 6 Nov 2003 01:38:39 -0000 1.51 *************** *** 221,224 **** --- 221,226 ---- public void addToBuckets(SimpleMicropolygon mp) { + if (mp.getMaxX() < rasterWindowMin.x || mp.getMaxY() < rasterWindowMin.y) + return; float mpMinX = mp.getMinX() - rasterWindowMin.x; float mpMinY = mp.getMinY() - rasterWindowMin.y; *************** *** 324,328 **** shaderVariables.transform(cameraToRaster); shaderVariables.getMicropolygons(this); ! sampler.sampleBucket(bucket); } else { Primitive[] sub = p.split(); --- 326,330 ---- shaderVariables.transform(cameraToRaster); shaderVariables.getMicropolygons(this); ! sampler.sampleBucket(bucket, bucket.hasMorePrimitives()); } else { Primitive[] sub = p.split(); *************** *** 335,339 **** } } ! sampler.sampleBucket(bucket); bucket.flush(); if (displayMode == Display.Mode.RGB || displayMode == Display.Mode.RGBA) { --- 337,342 ---- } } ! if (bucket.hasMoreMicropolygons()) ! sampler.sampleBucket(bucket, false); bucket.flush(); if (displayMode == Display.Mode.RGB || displayMode == Display.Mode.RGBA) { Index: SamplePoint.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SamplePoint.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SamplePoint.java 5 Nov 2003 04:13:12 -0000 1.15 --- SamplePoint.java 6 Nov 2003 01:38:39 -0000 1.16 *************** *** 34,38 **** private List samples = new ArrayList(); ! private List micropolygons = new ArrayList(100); private Sampler sampler; --- 34,38 ---- private List samples = new ArrayList(); ! // private Micropolygon micropolygons; private Sampler sampler; *************** *** 57,60 **** --- 57,61 ---- opaque = false; z = Constants.INFINITY; + // micropolygons = null; } *************** *** 147,163 **** } public void addMicropolygon(Micropolygon mp) { ! micropolygons.add(mp); } public boolean hasMoreMicropolygons() { ! return !micropolygons.isEmpty(); } public Micropolygon getNextMicropolygon() { ! Micropolygon result = (Micropolygon) micropolygons.get(micropolygons.size() - 1); ! micropolygons.remove(micropolygons.size() - 1); return result; } } --- 148,167 ---- } + /* public void addMicropolygon(Micropolygon mp) { ! mp.next = micropolygons; ! micropolygons = mp; } public boolean hasMoreMicropolygons() { ! return micropolygons != null; } public Micropolygon getNextMicropolygon() { ! Micropolygon result = micropolygons; ! micropolygons = result.next; return result; } + */ } Index: Sampler.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sampler.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Sampler.java 5 Nov 2003 04:13:12 -0000 1.13 --- Sampler.java 6 Nov 2003 01:38:39 -0000 1.14 *************** *** 124,128 **** } ! public void sampleBucket(Bucket bucket) { bucketSamplesCount++; modified = false; --- 124,128 ---- } ! public void sampleBucket(Bucket bucket, boolean hasMorePrimitives) { bucketSamplesCount++; modified = false; *************** *** 131,135 **** mp.sample(this); } ! if (modified) { modifiedSampleBucketsCount++; updatePyramid(); --- 131,135 ---- mp.sample(this); } ! if (modified && hasMorePrimitives) { modifiedSampleBucketsCount++; updatePyramid(); *************** *** 138,142 **** /* ! public void sampleBucket(Bucket bucket) { bucketSamplesCount++; modified = false; --- 138,142 ---- /* ! public void sampleBucket(Bucket bucket, boolean hasMorePrimitives) { bucketSamplesCount++; modified = false; *************** *** 148,151 **** --- 148,152 ---- Micropolygon mp = bucket.getNextMicropolygon(); int col = Calc.max((int) ((mp.getMinX() - min.x) / sampleWidth), 0); + mp.startCol = col; int row = Calc.max((int) ((mp.getMinY() - min.y) / sampleHeight), 0); getSamplePoint(col, row).addMicropolygon(mp); *************** *** 160,167 **** } float y = min.y + minRow * sampleHeight + sampleHeight; for (int row = minRow; row <= maxRow; row++) { float x = min.x + minCol * sampleWidth + sampleWidth; for (int col = minCol; col <= maxCol; col++) { ! SamplePoint sp = getSamplePoint(col, row); while (sp.hasMoreMicropolygons()) { Micropolygon mp = sp.getNextMicropolygon(); --- 161,169 ---- } float y = min.y + minRow * sampleHeight + sampleHeight; + int rowOffset = minRow * width; for (int row = minRow; row <= maxRow; row++) { float x = min.x + minCol * sampleWidth + sampleWidth; for (int col = minCol; col <= maxCol; col++) { ! SamplePoint sp = samplePoints[rowOffset + col]; while (sp.hasMoreMicropolygons()) { Micropolygon mp = sp.getNextMicropolygon(); *************** *** 169,183 **** mp.sampleAtPoint(sp); if (mp.getMaxX() >= x) { ! if (col < maxCol) ! getSamplePoint(col + 1, row).addMicropolygon(mp); else if (mp.getMaxY() >= y && row < maxRow) { ! int newCol = ! Calc.max((int) ((mp.getMinX() - min.x) / sampleWidth), 0); ! getSamplePoint(newCol, row + 1).addMicropolygon(mp); } } else if (mp.getMaxY() >= y && row < maxRow) { ! int newCol = ! Calc.max((int) ((mp.getMinX() - min.x) / sampleWidth), 0); ! getSamplePoint(newCol, row + 1).addMicropolygon(mp); } } --- 171,182 ---- mp.sampleAtPoint(sp); if (mp.getMaxX() >= x) { ! if (col < maxCol) { ! samplePoints[rowOffset + col + 1].addMicropolygon(mp); ! } else if (mp.getMaxY() >= y && row < maxRow) { ! samplePoints[rowOffset + width + mp.startCol].addMicropolygon(mp); } } else if (mp.getMaxY() >= y && row < maxRow) { ! samplePoints[rowOffset + width + mp.startCol].addMicropolygon(mp); } } *************** *** 185,190 **** } y += sampleHeight; } ! if (modified) { modifiedSampleBucketsCount++; updatePyramid(); --- 184,199 ---- } y += sampleHeight; + rowOffset += width; } ! for (int row = 0; row < height; row++) ! for (int col = 0; col < width; col++) { ! SamplePoint sp = getSamplePoint(col, row); ! if (sp.hasMoreMicropolygons()) { ! System.out.println("(" + col + ", " + row + ")"); ! System.out.println("col: " + minCol + " : " + maxCol); ! System.out.println("row: " + minRow + " : " + maxRow); ! } ! } ! if (modified && hasMorePrimitives) { modifiedSampleBucketsCount++; updatePyramid(); *************** *** 253,264 **** private void updatePyramid() { ! for (int row = 0; row < bucketHeight; row++) for (int column = 0; column < bucketWidth; column++) { ! MaskElement me = pixelsVisibility[row * bucketWidth + column]; if (!me.modified) continue; boolean opaque = true; float z = -Constants.INFINITY; ! CheckOpacity : for (int r = 0; r < pixelHeight; r++) for (int c = 0; c < pixelWidth; c++) { SamplePoint sp = --- 262,275 ---- private void updatePyramid() { ! int rowOffset = 0; ! boolean changed = false; ! for (int row = 0; row < bucketHeight; row++) { for (int column = 0; column < bucketWidth; column++) { ! MaskElement me = pixelsVisibility[rowOffset + column]; if (!me.modified) continue; boolean opaque = true; float z = -Constants.INFINITY; ! CheckOpacity : for (int r = 0; r < pixelHeight; r++) { for (int c = 0; c < pixelWidth; c++) { SamplePoint sp = *************** *** 268,281 **** break CheckOpacity; } else ! z = Math.max(z, sp.getZ()); } if (opaque) { if (z < me.z) { me.opaque = true; me.z = z; } } } ! updateRoot(); } --- 279,297 ---- break CheckOpacity; } else ! z = Calc.max(z, sp.getZ()); } + } if (opaque) { if (z < me.z) { me.opaque = true; me.z = z; + changed = true; } } } ! rowOffset += bucketWidth; ! } ! if (changed) ! updateRoot(); } *************** *** 288,292 **** break; } ! z = Math.max(z, pixelsVisibility[i].z); } if (rootVisibility.opaque) --- 304,308 ---- break; } ! z = Calc.max(z, pixelsVisibility[i].z); } if (rootVisibility.opaque) Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SimpleMicropolygon.java 5 Nov 2003 04:13:12 -0000 1.11 --- SimpleMicropolygon.java 6 Nov 2003 01:38:39 -0000 1.12 *************** *** 29,33 **** import org.jrman.util.Calc; - import org.jrman.util.Constants; public class SimpleMicropolygon extends Micropolygon { --- 29,32 ---- *************** *** 84,97 **** private float opacityBlue; - private float minX = Constants.INFINITY; - - private float maxX = -Constants.INFINITY; - - private float minY = Constants.INFINITY; - - private float maxY = -Constants.INFINITY; - - private float minZ = Constants.INFINITY; - public void write(DataOutputStream dos) throws IOException { dos.writeFloat(ax); --- 83,86 ---- *************** *** 258,281 **** z); return; - } - - public float getMaxX() { - return maxX; - } - - public float getMaxY() { - return maxY; - } - - public float getMinX() { - return minX; - } - - public float getMinY() { - return minY; - } - - public float getMinZ() { - return minZ; } --- 247,250 ---- |
From: <ma...@us...> - 2003-11-05 04:13:19
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1:/tmp/cvs-serv27734/sampleData Added Files: jrm Log Message: Micropolygons sampling tests. --- NEW FILE: jrm --- export CLASSPATH=../build:../lib/vecmath.jar:../src export MEMORY=160m java -server -Xms$MEMORY -Xmx$MEMORY org.jrman.main.JRMan $* |
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv27734/src/org/jrman/render Modified Files: Bucket.java FileBucket.java MemoryBucket.java Micropolygon.java SamplePoint.java Sampler.java SimpleMicropolygon.java Log Message: Micropolygons sampling tests. Index: Bucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Bucket.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Bucket.java 17 Jul 2003 04:03:11 -0000 1.8 --- Bucket.java 5 Nov 2003 04:13:12 -0000 1.9 *************** *** 39,42 **** void prefetchMicropolygons(); ! ! } \ No newline at end of file --- 39,42 ---- void prefetchMicropolygons(); ! ! } Index: FileBucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/FileBucket.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FileBucket.java 17 Jul 2003 16:35:48 -0000 1.4 --- FileBucket.java 5 Nov 2003 04:13:12 -0000 1.5 *************** *** 157,160 **** micropolygons = new NullStack(); } ! } --- 157,160 ---- micropolygons = new NullStack(); } ! } Index: MemoryBucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/MemoryBucket.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MemoryBucket.java 17 Jul 2003 16:35:48 -0000 1.3 --- MemoryBucket.java 5 Nov 2003 04:13:12 -0000 1.4 *************** *** 79,82 **** public void prefetchMicropolygons() { } ! } --- 79,82 ---- public void prefetchMicropolygons() { } ! } Index: Micropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Micropolygon.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Micropolygon.java 8 Sep 2003 23:03:29 -0000 1.13 --- Micropolygon.java 5 Nov 2003 04:13:12 -0000 1.14 *************** *** 25,29 **** ! public abstract class Micropolygon { public static int count; --- 25,29 ---- ! public abstract class Micropolygon implements Comparable { public static int count; *************** *** 35,37 **** public abstract void read(DataInputStream dis) throws IOException; ! } \ No newline at end of file --- 35,48 ---- public abstract void read(DataInputStream dis) throws IOException; ! public abstract void sampleAtPoint(SamplePoint sp); ! ! public abstract float getMinX(); ! ! public abstract float getMinY(); ! ! public abstract float getMaxX(); ! ! public abstract float getMaxY(); ! ! public abstract float getMinZ(); ! } Index: SamplePoint.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SamplePoint.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SamplePoint.java 3 Nov 2003 07:37:25 -0000 1.14 --- SamplePoint.java 5 Nov 2003 04:13:12 -0000 1.15 *************** *** 34,37 **** --- 34,39 ---- private List samples = new ArrayList(); + private List micropolygons = new ArrayList(100); + private Sampler sampler; *************** *** 143,146 **** --- 145,162 ---- public float getZ() { return z; + } + + public void addMicropolygon(Micropolygon mp) { + micropolygons.add(mp); + } + + public boolean hasMoreMicropolygons() { + return !micropolygons.isEmpty(); + } + + public Micropolygon getNextMicropolygon() { + Micropolygon result = (Micropolygon) micropolygons.get(micropolygons.size() - 1); + micropolygons.remove(micropolygons.size() - 1); + return result; } Index: Sampler.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sampler.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Sampler.java 3 Nov 2003 07:37:25 -0000 1.12 --- Sampler.java 5 Nov 2003 04:13:12 -0000 1.13 *************** *** 20,23 **** --- 20,26 ---- package org.jrman.render; + import java.util.Collections; + import java.util.List; + import javax.vecmath.Color3f; import javax.vecmath.Point2f; *************** *** 134,137 **** --- 137,196 ---- } + /* + public void sampleBucket(Bucket bucket) { + bucketSamplesCount++; + modified = false; + int minRow = height; + int maxRow = -1; + int minCol = width; + int maxCol = -1; + while (bucket.hasMoreMicropolygons()) { + Micropolygon mp = bucket.getNextMicropolygon(); + int col = Calc.max((int) ((mp.getMinX() - min.x) / sampleWidth), 0); + int row = Calc.max((int) ((mp.getMinY() - min.y) / sampleHeight), 0); + getSamplePoint(col, row).addMicropolygon(mp); + minCol = Calc.min(minCol, col); + maxCol = Calc.max(maxCol, + Calc.min((int) ((mp.getMaxX() - min.x) / sampleWidth), + width - 1)); + minRow = Calc.min(minRow, row); + maxRow = Calc.max(maxRow, + Calc.min((int) ((mp.getMaxY() - min.y) / sampleHeight), + height - 1)); + } + float y = min.y + minRow * sampleHeight + sampleHeight; + for (int row = minRow; row <= maxRow; row++) { + float x = min.x + minCol * sampleWidth + sampleWidth; + for (int col = minCol; col <= maxCol; col++) { + SamplePoint sp = getSamplePoint(col, row); + while (sp.hasMoreMicropolygons()) { + Micropolygon mp = sp.getNextMicropolygon(); + if (!sp.isOpaque() || sp.getZ() >= mp.getMinZ()) + mp.sampleAtPoint(sp); + if (mp.getMaxX() >= x) { + if (col < maxCol) + getSamplePoint(col + 1, row).addMicropolygon(mp); + else if (mp.getMaxY() >= y && row < maxRow) { + int newCol = + Calc.max((int) ((mp.getMinX() - min.x) / sampleWidth), 0); + getSamplePoint(newCol, row + 1).addMicropolygon(mp); + } + } else if (mp.getMaxY() >= y && row < maxRow) { + int newCol = + Calc.max((int) ((mp.getMinX() - min.x) / sampleWidth), 0); + getSamplePoint(newCol, row + 1).addMicropolygon(mp); + } + } + x += sampleWidth; + } + y += sampleHeight; + } + if (modified) { + modifiedSampleBucketsCount++; + updatePyramid(); + } + } + */ + public void getColors( float[] dst, Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SimpleMicropolygon.java 3 Nov 2003 08:35:41 -0000 1.10 --- SimpleMicropolygon.java 5 Nov 2003 04:13:12 -0000 1.11 *************** *** 276,278 **** --- 276,291 ---- } + public float getMinZ() { + return minZ; + } + + public int compareTo(Object other) { + Micropolygon mp = (Micropolygon) other; + if (maxX < mp.getMaxX()) + return -1; + if (maxX > mp.getMaxX()) + return 1; + return 0; + } + } |
From: <ma...@us...> - 2003-11-04 04:57:48
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1:/tmp/cvs-serv19927/src/org/jrman/shaders Modified Files: SurfaceShader.java Log Message: More performance optimizations. Index: SurfaceShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/SurfaceShader.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SurfaceShader.java 4 Jun 2003 14:54:56 -0000 1.14 --- SurfaceShader.java 4 Nov 2003 04:57:44 -0000 1.15 *************** *** 53,56 **** --- 53,58 ---- static FloatGrid _fg2 = new FloatGrid(); + static FloatGrid _fg3 = new FloatGrid(); + static Vector3fGrid _vg1 = new Vector3fGrid(); *************** *** 125,129 **** }); } ! protected void specular( ShaderVariables sv, --- 127,131 ---- }); } ! protected void specular( ShaderVariables sv, *************** *** 144,148 **** _fg2.dot(Nn, H); _fg2.max(_fg2, 0f); ! _fg2.pow(_fg2, 10f / roughness); nonspec.sub(1, nonspec); _fg2.mul(_fg2, nonspec); --- 146,151 ---- _fg2.dot(Nn, H); _fg2.max(_fg2, 0f); ! //_fg2.pow(_fg2, 10f / roughness); ! _fg2.simulPow(_fg2, 18f / roughness); nonspec.sub(1, nonspec); _fg2.mul(_fg2, nonspec); |
From: <ma...@us...> - 2003-11-04 04:57:48
|
Update of /cvsroot/jrman/drafts/src/org/jrman/grid In directory sc8-pr-cvs1:/tmp/cvs-serv19927/src/org/jrman/grid Modified Files: FloatGrid.java Log Message: More performance optimizations. Index: FloatGrid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/grid/FloatGrid.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** FloatGrid.java 25 Oct 2003 05:46:46 -0000 1.16 --- FloatGrid.java 4 Nov 2003 04:57:44 -0000 1.17 *************** *** 1238,1240 **** --- 1238,1252 ---- } + /* + * simulPow + */ + + public void simulPow(FloatGrid f1, float n) + { + for (int i = 0; i < size; i++) { + float t = f1.data[i]; + data[i] = t / (n - n * t + t); + } + } + } |
From: <ma...@us...> - 2003-11-03 16:35:09
|
Update of /cvsroot/jrman/drafts/src/org/jrman/util In directory sc8-pr-cvs1:/tmp/cvs-serv7230/src/org/jrman/util Modified Files: Calc.java Log Message: Fixed end of frame statistics when rendering multiple frames. Index: Calc.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/util/Calc.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Calc.java 13 Aug 2003 03:59:38 -0000 1.10 --- Calc.java 3 Nov 2003 16:35:06 -0000 1.11 *************** *** 32,37 **** } public static int clamp(int v, int min, int max) { ! return Math.min(Math.max(v, min), max); } --- 32,45 ---- } + public static int min(int a, int b) { + return a < b ? a : b; + } + + public static int max(int a, int b) { + return a > b ? a : b; + } + public static int clamp(int v, int min, int max) { ! return min(max(v, min), max); } *************** *** 63,68 **** } public static float clamp(float v, float min, float max) { ! return Math.min(Math.max(v, min), max); } --- 71,84 ---- } + public static float min(float a, float b) { + return a < b ? a : b; + } + + public static float max(float a, float b) { + return a > b ? a : b; + } + public static float clamp(float v, float min, float max) { ! return min(max(v, min), max); } |
From: <ma...@us...> - 2003-11-03 16:35:08
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv7230/src/org/jrman/render Modified Files: RendererHidden.java Log Message: Fixed end of frame statistics when rendering multiple frames. Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** RendererHidden.java 31 Oct 2003 03:03:15 -0000 1.49 --- RendererHidden.java 3 Nov 2003 16:35:05 -0000 1.50 *************** *** 468,471 **** --- 468,479 ---- "Modified bucket samples: " + Sampler.modifiedSampleBucketsCount); System.out.println("---------------------------------------------------"); + primitivePatchCount = 0; + invisiblePatchCount = 0; + Sampler.rootCount = 0; + Sampler.pixelCount = 0; + gridCount = 0; + Micropolygon.count = 0; + Sampler.bucketSamplesCount = 0; + Sampler.modifiedSampleBucketsCount = 0; } } |
From: <ma...@us...> - 2003-11-03 08:35:47
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv14551/src/org/jrman/render Modified Files: SimpleMicropolygon.java Log Message: Removed mp optimization (too much memory...) Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SimpleMicropolygon.java 3 Nov 2003 07:37:25 -0000 1.9 --- SimpleMicropolygon.java 3 Nov 2003 08:35:41 -0000 1.10 *************** *** 54,57 **** --- 54,58 ---- private float cy; + /* private float ayby; *************** *** 65,68 **** --- 66,70 ---- private float axcx; + */ private float nxOverZ; *************** *** 100,103 **** --- 102,106 ---- dos.writeFloat(cx); dos.writeFloat(cy); + /* dos.writeFloat(ayby); dos.writeFloat(bxax); *************** *** 106,109 **** --- 109,113 ---- dos.writeFloat(cyay); dos.writeFloat(axcx); + */ dos.writeFloat(nxOverZ); dos.writeFloat(nyOverZ); *************** *** 129,132 **** --- 133,137 ---- cx = dis.readFloat(); cy = dis.readFloat(); + /* ayby = dis.readFloat(); bxax = dis.readFloat(); *************** *** 135,138 **** --- 140,144 ---- cyay = dis.readFloat(); axcx = dis.readFloat(); + */ nxOverZ = dis.readFloat(); nyOverZ = dis.readFloat(); *************** *** 185,188 **** --- 191,195 ---- cx = c.x; cy = c.y; + /* ayby = ay - by; bxax = bx - ax; *************** *** 191,194 **** --- 198,202 ---- cyay = cy - ay; axcx = ax - cx; + */ colorRed = cRed; colorGreen = cGreen; *************** *** 234,242 **** public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); ! if ((ayby) * (point.x - ax) + (bxax) * (point.y - ay) > 0f) return; ! if ((bycy) * (point.x - bx) + (cxbx) * (point.y - by) > 0f) return; ! if ((cyay) * (point.x - cx) + (axcx) * (point.y - cy) > 0f) return; float z = nxOverZ * (ax - point.x) + nyOverZ * (ay - point.y) + az; --- 242,250 ---- public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); ! if ((ay - by) * (point.x - ax) + (bx - ax) * (point.y - ay) > 0f) return; ! if ((by - cy) * (point.x - bx) + (cx - bx) * (point.y - by) > 0f) return; ! if ((cy - ay) * (point.x - cx) + (ax - cx) * (point.y - cy) > 0f) return; float z = nxOverZ * (ax - point.x) + nyOverZ * (ay - point.y) + az; |
From: <ma...@us...> - 2003-11-03 07:37:28
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv5688/src/org/jrman/render Modified Files: SimpleMicropolygon.java SamplePoint.java Sample.java Sampler.java Log Message: Small performance improvements. Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SimpleMicropolygon.java 8 Sep 2003 23:03:29 -0000 1.8 --- SimpleMicropolygon.java 3 Nov 2003 07:37:25 -0000 1.9 *************** *** 54,57 **** --- 54,69 ---- private float cy; + private float ayby; + + private float bxax; + + private float bycy; + + private float cxbx; + + private float cyay; + + private float axcx; + private float nxOverZ; *************** *** 88,91 **** --- 100,109 ---- dos.writeFloat(cx); dos.writeFloat(cy); + dos.writeFloat(ayby); + dos.writeFloat(bxax); + dos.writeFloat(bycy); + dos.writeFloat(cxbx); + dos.writeFloat(cyay); + dos.writeFloat(axcx); dos.writeFloat(nxOverZ); dos.writeFloat(nyOverZ); *************** *** 111,114 **** --- 129,138 ---- cx = dis.readFloat(); cy = dis.readFloat(); + ayby = dis.readFloat(); + bxax = dis.readFloat(); + bycy = dis.readFloat(); + cxbx = dis.readFloat(); + cyay = dis.readFloat(); + axcx = dis.readFloat(); nxOverZ = dis.readFloat(); nyOverZ = dis.readFloat(); *************** *** 161,164 **** --- 185,194 ---- cx = c.x; cy = c.y; + ayby = ay - by; + bxax = bx - ax; + bycy = by - cy; + cxbx = cx - bx; + cyay = cy - ay; + axcx = ax - cx; colorRed = cRed; colorGreen = cGreen; *************** *** 204,212 **** public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); ! if ((ay - by) * (point.x - ax) + (bx - ax) * (point.y - ay) > 0f) return; ! if ((by - cy) * (point.x - bx) + (cx - bx) * (point.y - by) > 0f) return; ! if ((cy - ay) * (point.x - cx) + (ax - cx) * (point.y - cy) > 0f) return; float z = nxOverZ * (ax - point.x) + nyOverZ * (ay - point.y) + az; --- 234,242 ---- public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); ! if ((ayby) * (point.x - ax) + (bxax) * (point.y - ay) > 0f) return; ! if ((bycy) * (point.x - bx) + (cxbx) * (point.y - by) > 0f) return; ! if ((cyay) * (point.x - cx) + (axcx) * (point.y - cy) > 0f) return; float z = nxOverZ * (ax - point.x) + nyOverZ * (ay - point.y) + az; Index: SamplePoint.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SamplePoint.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SamplePoint.java 20 Aug 2003 20:41:21 -0000 1.13 --- SamplePoint.java 3 Nov 2003 07:37:25 -0000 1.14 *************** *** 34,41 **** private List samples = new ArrayList(); - private Color3f color = new Color3f(); - - private Color3f opacity = new Color3f(); - private Sampler sampler; --- 34,37 ---- *************** *** 122,131 **** while (i > 0) { Sample sample = (Sample) samples.get(--i); ! sample.getOpacity(opacity); ! ocolor.x *= (1f - opacity.x); ! ocolor.y *= (1f - opacity.y); ! ocolor.z *= (1f - opacity.z); ! sample.getColor(color); ! ocolor.add(color); } } --- 118,122 ---- while (i > 0) { Sample sample = (Sample) samples.get(--i); ! sample.overlayOver(ocolor); } } Index: Sample.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sample.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Sample.java 18 Jul 2003 08:40:24 -0000 1.4 --- Sample.java 3 Nov 2003 07:37:25 -0000 1.5 *************** *** 61,74 **** } ! public void getColor(Color3f color) { ! color.x = colorRed; ! color.y = colorGreen; ! color.z = colorBlue; ! } ! ! public void getOpacity(Color3f opacity) { ! opacity.x = opacityRed; ! opacity.y = opacityGreen; ! opacity.z = opacityBlue; } --- 61,68 ---- } ! public void overlayOver(Color3f ocolor) { ! ocolor.x = ocolor.x * (1f - opacityRed) + colorRed; ! ocolor.y = ocolor.y * (1f - opacityGreen) + colorGreen; ! ocolor.z = ocolor.z * (1f - opacityBlue) + colorBlue; } Index: Sampler.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sampler.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Sampler.java 8 Sep 2003 23:03:29 -0000 1.11 --- Sampler.java 3 Nov 2003 07:37:25 -0000 1.12 *************** *** 104,107 **** --- 104,108 ---- min.set(minX, minY); float y = min.y + sampleHeight * .5f; + int offset = 0; for (int row = 0; row < height; row++) { float x = min.x + sampleWidth * .5f; *************** *** 109,115 **** float jx = x + (Rand.uniform() - .5f) * sampleWidth; float jy = y + (Rand.uniform() - .5f) * sampleHeight; ! samplePoints[row * width + column].init(jx, jy); x += sampleWidth; } y += sampleHeight; } --- 110,117 ---- float jx = x + (Rand.uniform() - .5f) * sampleWidth; float jy = y + (Rand.uniform() - .5f) * sampleHeight; ! samplePoints[offset + column].init(jx, jy); x += sampleWidth; } + offset += width; y += sampleHeight; } *************** *** 138,151 **** int bands, int bandOffset) { ! for (int row = 0; row < height; row++) for (int col = 0; col < width; col++) { ! samplePoints[row * width + col].getColor(tmpColor); ! int offset = dstOffset + (row * rowLength + col) * bands + bandOffset; dst[offset++] = tmpColor.x; dst[offset++] = tmpColor.y; dst[offset] = tmpColor.z; } } ! public void getDepths(float[] depths) { for (int row = 0; row < height; row++) --- 140,158 ---- int bands, int bandOffset) { ! int srcOffset = 0; ! int destOffset = dstOffset + bandOffset; ! for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { ! samplePoints[srcOffset + col].getColor(tmpColor); ! int offset = destOffset + col * bands; dst[offset++] = tmpColor.x; dst[offset++] = tmpColor.y; dst[offset] = tmpColor.z; } + srcOffset += width; + destOffset += rowLength * bands; + } } ! public void getDepths(float[] depths) { for (int row = 0; row < height; row++) |
From: <ma...@us...> - 2003-10-31 03:03:18
|
Update of /cvsroot/jrman/drafts/src/org/jrman/maps In directory sc8-pr-cvs1:/tmp/cvs-serv19369/src/org/jrman/maps Modified Files: ShadowMap.java MipMap.java Log Message: Does its best to release memory mapped files before writting to a file with the same name. Commented framebuffer title update for each bucket (it consumed up to 50% of cpu time for simple images!!!) Index: ShadowMap.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/maps/ShadowMap.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ShadowMap.java 23 Aug 2003 21:22:46 -0000 1.4 --- ShadowMap.java 31 Oct 2003 03:03:15 -0000 1.5 *************** *** 128,134 **** for (int i = 0; i < depths.length; i++) dos.writeFloat(depths[i]); - dos.flush(); dos.close(); - fos.close(); } --- 128,132 ---- *************** *** 147,150 **** --- 145,149 ---- public static void flushShadowMap(String filename) { map.remove(filename); + System.gc(); // Hope the mapped file is released.... } Index: MipMap.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/maps/MipMap.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MipMap.java 3 Jul 2003 17:57:52 -0000 1.3 --- MipMap.java 31 Oct 2003 03:03:15 -0000 1.4 *************** *** 192,196 **** } dos.close(); - flushMipMap(filename); } --- 192,195 ---- *************** *** 204,207 **** --- 203,207 ---- float tWidth) throws IOException { + flushMipMap(filename); File file = new File(imageFilename); BufferedImage image = ImageIO.read(file); *************** *** 228,231 **** --- 228,232 ---- public static void flushMipMap(String filename) { map.remove(filename); + System.gc(); // Hope the mapped file is released..... } |
From: <ma...@us...> - 2003-10-31 03:03:18
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv19369/src/org/jrman/render Modified Files: RendererHidden.java Log Message: Does its best to release memory mapped files before writting to a file with the same name. Commented framebuffer title update for each bucket (it consumed up to 50% of cpu time for simple images!!!) Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** RendererHidden.java 21 Oct 2003 01:58:40 -0000 1.48 --- RendererHidden.java 31 Oct 2003 03:03:15 -0000 1.49 *************** *** 249,255 **** frame.getDisplay()); ZStore zStore = null; ! if (displayMode == Display.Mode.Z) zStore = new ZStore(frame.getHorizontalResolution(), frame.getVerticalResolution()); Framebuffer fb = null; if (displayType == Display.Type.FRAMEBUFFER) { --- 249,257 ---- frame.getDisplay()); ZStore zStore = null; ! if (displayMode == Display.Mode.Z) { zStore = new ZStore(frame.getHorizontalResolution(), frame.getVerticalResolution()); + ShadowMap.flushShadowMap(frame.getDisplay().getName()); + } Framebuffer fb = null; if (displayType == Display.Type.FRAMEBUFFER) { *************** *** 373,380 **** if (fb != null) fb.refresh( ! column * bucketWidth - (column == 0 ? 0 : hPixelLess) + (int) rmin.x, ! row * bucketHeight - (row == 0 ? 0 : vPixelLess) + (int) rmin.y, ! bucketWidth - (column == 0 ? hPixelLess : 0), ! bucketHeight - (row == 0 ? vPixelLess : 0)); } else if (displayMode == Display.Mode.Z) { sampler.getDepths(depths); --- 375,384 ---- if (fb != null) fb.refresh( ! column * bucketWidth ! - (column == 0 ? 0 : hPixelLess) ! + (int) rmin.x, ! row * bucketHeight - (row == 0 ? 0 : vPixelLess) + (int) rmin.y, ! bucketWidth - (column == 0 ? hPixelLess : 0), ! bucketHeight - (row == 0 ? vPixelLess : 0)); } else if (displayMode == Display.Mode.Z) { sampler.getDepths(depths); *************** *** 412,419 **** * 3); } ! if (displayType == Display.Type.FRAMEBUFFER) { ! System.out.println(); ! fb.completed(); ! }else if (displayType == Display.Type.FILE) try { if (displayMode == Display.Mode.RGB || displayMode == Display.Mode.RGBA) { --- 416,423 ---- * 3); } ! if (displayType == Display.Type.FRAMEBUFFER) { ! System.out.println(); ! fb.completed(); ! } else if (displayType == Display.Type.FILE) try { if (displayMode == Display.Mode.RGB || displayMode == Display.Mode.RGBA) { |
From: <ma...@us...> - 2003-10-31 03:03:17
|
Update of /cvsroot/jrman/drafts/src/org/jrman/ui In directory sc8-pr-cvs1:/tmp/cvs-serv19369/src/org/jrman/ui Modified Files: Framebuffer.java Log Message: Does its best to release memory mapped files before writting to a file with the same name. Commented framebuffer title update for each bucket (it consumed up to 50% of cpu time for simple images!!!) Index: Framebuffer.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/ui/Framebuffer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Framebuffer.java 21 Oct 2003 01:58:40 -0000 1.2 --- Framebuffer.java 31 Oct 2003 03:03:15 -0000 1.3 *************** *** 1,86 **** ! /* ! Framebuffer.java ! Copyright (C) 2003 Alessandro Falappa ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program 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. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ ! package org.jrman.ui; ! ! import java.awt.image.BufferedImage; ! ! import javax.swing.ImageIcon; ! import javax.swing.JFrame; ! ! import net.falappa.imageio.ImageViewerPanelSaveAction; ! import net.falappa.swing.widgets.JImageViewerPanel; ! ! /** ! * The window of the framebuffer display. ! * It shows the image being rendered, when finished allows to save the image to ! * a file. It allows to scroll and zoom the image. ! * ! * @author Alessandro Falappa ! */ ! public class Framebuffer extends JFrame { ! private JImageViewerPanel imagePanel= new JImageViewerPanel(); ! private ImageViewerPanelSaveAction save; ! private StringBuffer sb= new StringBuffer(); ! private String name; ! ! /** ! * @param display ! * @param image ! */ ! public Framebuffer(String name, BufferedImage image) { ! super(name); ! this.name= name; ! save = new ImageViewerPanelSaveAction(imagePanel,image.getType()); ! save.setEnabled(false); ! imagePanel.setImage(image); ! imagePanel.addToolbarAction(save); ! if (image.getType() == BufferedImage.TYPE_INT_ARGB ! || image.getType() == BufferedImage.TYPE_INT_ARGB_PRE) { ! imagePanel.setShowTransparency(true); ! } ! setIconImage( ! new ImageIcon( ! getClass().getResource("images/framebuffer_icon.png")) ! .getImage()); ! setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ! getContentPane().add(imagePanel); ! pack(); ! } ! ! /** ! * ! * @param x ! * @param y ! * @param w ! * @param h ! */ ! public void refresh(int x, int y, int w, int h) { ! imagePanel.repaintImage(x, y, w, h); ! sb.setLength(0); ! sb.append(name).append(" - bucket["); ! sb.append(x).append(',').append(y).append(']'); ! setTitle(sb.toString()); ! } ! ! public void completed() { ! save.setEnabled(true); ! setTitle(name); ! sb=null; ! } ! } --- 1,87 ---- ! /* ! Framebuffer.java ! Copyright (C) 2003 Alessandro Falappa ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program 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. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ ! package org.jrman.ui; ! ! import java.awt.image.BufferedImage; ! ! import javax.swing.ImageIcon; ! import javax.swing.JFrame; ! ! import net.falappa.imageio.ImageViewerPanelSaveAction; ! import net.falappa.swing.widgets.JImageViewerPanel; ! ! /** ! * The window of the framebuffer display. ! * It shows the image being rendered, when finished allows to save the image to ! * a file. It allows to scroll and zoom the image. ! * ! * @author Alessandro Falappa ! */ ! public class Framebuffer extends JFrame { ! private JImageViewerPanel imagePanel = new JImageViewerPanel(); ! private ImageViewerPanelSaveAction save; ! private StringBuffer sb = new StringBuffer(); ! private String name; ! ! /** ! * @param display ! * @param image ! */ ! public Framebuffer(String name, BufferedImage image) { ! super(name); ! this.name = name; ! save = new ImageViewerPanelSaveAction(imagePanel, image.getType()); ! save.setEnabled(false); ! imagePanel.setImage(image); ! imagePanel.addToolbarAction(save); ! if (image.getType() == BufferedImage.TYPE_INT_ARGB ! || image.getType() == BufferedImage.TYPE_INT_ARGB_PRE) { ! imagePanel.setShowTransparency(true); ! } ! setIconImage( ! new ImageIcon(getClass().getResource("images/framebuffer_icon.png")).getImage()); ! setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ! getContentPane().add(imagePanel); ! pack(); ! } ! ! /** ! * ! * @param x ! * @param y ! * @param w ! * @param h ! */ ! public void refresh(int x, int y, int w, int h) { ! imagePanel.repaintImage(x, y, w, h); ! /* ! Commented this because updating the title for each bucket usesup to 50% of CPU time!!!! ! sb.setLength(0); ! sb.append(name).append(" - bucket["); ! sb.append(x).append(',').append(y).append(']'); ! setTitle(sb.toString()); ! */ ! } ! ! public void completed() { ! save.setEnabled(true); ! setTitle(name); ! sb = null; ! } ! } |
From: <ma...@us...> - 2003-10-28 16:58:52
|
Update of /cvsroot/jrman/drafts/scheme In directory sc8-pr-cvs1:/tmp/cvs-serv18515/scheme Modified Files: comp.scm pru.comp Log Message: Reorganized code generation. Implemented unary minus code generation. Index: comp.scm =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/comp.scm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** comp.scm 28 Oct 2003 04:57:30 -0000 1.7 --- comp.scm 28 Oct 2003 16:58:44 -0000 1.8 *************** *** 187,222 **** (define (generate-code tree) (letrec ((code ()) (emit-code (lambda (c) (set! code (cons c code)))) (gencode ! (lambda (tree) ! (if (not (pair? tree)) ! tree ! (case (car tree) ((begin) ! (let loop ((l (cdr tree))) ! (if (not (null? l)) ! (begin (gencode (car l)) ! (loop (cdr l)))))) ((declare) ! (add-symbol (cadr tree) #f (caddr tree) (cadddr tree))) ((set!) ! (emit-code `(store! ,(cadr tree) ,(gencode (caddr tree))))) ((+) ! (let ((tmp (gentemp))) ! (emit-code `(+! ,tmp ,(gencode (cadr tree)) ,(gencode (caddr tree)))) ! tmp)) ((-) ! (let ((tmp (gentemp))) ! (emit-code `(-! ,tmp ,(gencode (cadr tree)) ,(gencode (caddr tree)))) ! tmp)) ((*) ! (let ((tmp (gentemp))) ! (emit-code `(*! ,tmp ,(gencode (cadr tree)) ,(gencode (caddr tree)))) ! tmp)) ((/) ! (let ((tmp (gentemp))) ! (emit-code `(/! ,tmp ,(gencode (cadr tree)) ,(gencode (caddr tree)))) ! tmp))))))) (gencode tree) (reverse code))) --- 187,254 ---- (define (generate-code tree) (letrec ((code ()) + (emit-code (lambda (c) (set! code (cons c code)))) + + (gencode-declare + (lambda (l) + (add-symbol (car l) #f (cadr l) (caddr l)))) + + (gencode-begin + (lambda (l) + (if (not (null? l)) + (begin (gencode (car l)) + (gencode-begin (cdr l)))))) + + (gencode-store! + (lambda (l) + (emit-code `(store! ,(car l) ,(gencode (cadr l)))))) + + (gencode+! + (lambda (l) + (let ((tmp (gentemp))) + (emit-code `(+! ,tmp ,(gencode (car l)) ,(gencode (cadr l)))) + tmp))) + + (gencode-! + (lambda (l) + (let ((tmp (gentemp))) + (if (= 2 (length l)) + (emit-code `(-! ,tmp ,(gencode (car l)) ,(gencode (cadr l)))) + (emit-code `(-u! ,tmp ,(gencode (car l))))) + tmp))) + + (gencode*! + (lambda (l) + (let ((tmp (gentemp))) + (emit-code `(*! ,tmp ,(gencode (car l)) ,(gencode (cadr l)))) + tmp))) + + (gencode/! + (lambda (l) + (let ((tmp (gentemp))) + (emit-code `(/! ,tmp ,(gencode (car l)) ,(gencode (cadr l)))) + tmp))) + (gencode ! (lambda (l) ! (if (not (pair? l)) ! l ! (case (car l) ((begin) ! (gencode-begin (cdr l))) ((declare) ! (gencode-declare (cdr l))) ((set!) ! (gencode-store! (cdr l))) ((+) ! (gencode+! (cdr l))) ((-) ! (gencode-! (cdr l))) ((*) ! (gencode*! (cdr l))) ((/) ! (gencode/! (cdr l)))))))) ! (gencode tree) (reverse code))) Index: pru.comp =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/pru.comp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pru.comp 28 Oct 2003 04:57:30 -0000 1.4 --- pru.comp 28 Oct 2003 16:58:44 -0000 1.5 *************** *** 4,8 **** tuple d; a = 2 * 6 + 3 * 5; ! b = a + 1; ! c = a + b * 15; d = a + b + c --- 4,8 ---- tuple d; a = 2 * 6 + 3 * 5; ! b = a - 1; ! c = a + -b / 15; d = a + b + c |
From: <ma...@us...> - 2003-10-28 05:03:33
|
Update of /cvsroot/jrman/drafts/scheme In directory sc8-pr-cvs1:/tmp/cvs-serv1892/scheme Modified Files: comp.scm pru.comp Log Message: Implemented basic "quadruples" generation. Index: comp.scm =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/comp.scm,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** comp.scm 27 Oct 2003 16:37:28 -0000 1.6 --- comp.scm 28 Oct 2003 04:57:30 -0000 1.7 *************** *** 156,159 **** --- 156,222 ---- ;; ---------------------------------------------------------------------- ;; + ;; Symbol table ;; + ;; ---------------------------------------------------------------------- ;; + (define (make-entry name temporary type sclass) + `(,name ,temporary ,type ,sclass)) + + (define (entry-name entry) + (car entry)) + + (define (entry-temporary entry) + (cadr entry)) + + (define (entry-type entry) + (caddr entry)) + + (define (entry-sclass entry) + (cadddr entry)) + + (define *symbol-table* ()) + + (define (lookup name) + (assq name *symbol-table*)) + + (define (add-symbol name temporary type sclass) + (set! *symbol-table* + (cons (make-entry name temporary type sclass) *symbol-table*))) + + ;; ---------------------------------------------------------------------- ;; ;; Code generator ;; ;; ---------------------------------------------------------------------- ;; + (define (generate-code tree) + (letrec ((code ()) + (emit-code + (lambda (c) (set! code (cons c code)))) + (gencode + (lambda (tree) + (if (not (pair? tree)) + tree + (case (car tree) + ((begin) + (let loop ((l (cdr tree))) + (if (not (null? l)) + (begin (gencode (car l)) + (loop (cdr l)))))) + ((declare) + (add-symbol (cadr tree) #f (caddr tree) (cadddr tree))) + ((set!) + (emit-code `(store! ,(cadr tree) ,(gencode (caddr tree))))) + ((+) + (let ((tmp (gentemp))) + (emit-code `(+! ,tmp ,(gencode (cadr tree)) ,(gencode (caddr tree)))) + tmp)) + ((-) + (let ((tmp (gentemp))) + (emit-code `(-! ,tmp ,(gencode (cadr tree)) ,(gencode (caddr tree)))) + tmp)) + ((*) + (let ((tmp (gentemp))) + (emit-code `(*! ,tmp ,(gencode (cadr tree)) ,(gencode (caddr tree)))) + tmp)) + ((/) + (let ((tmp (gentemp))) + (emit-code `(/! ,tmp ,(gencode (cadr tree)) ,(gencode (caddr tree)))) + tmp))))))) + (gencode tree) + (reverse code))) \ No newline at end of file Index: pru.comp =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/pru.comp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pru.comp 27 Oct 2003 15:40:15 -0000 1.3 --- pru.comp 28 Oct 2003 04:57:30 -0000 1.4 *************** *** 6,9 **** b = a + 1; c = a + b * 15; ! d = a + b + c; ! d \ No newline at end of file --- 6,8 ---- b = a + 1; c = a + b * 15; ! d = a + b + c \ No newline at end of file |
From: <ma...@us...> - 2003-10-27 16:41:57
|
Update of /cvsroot/jrman/drafts/scheme In directory sc8-pr-cvs1:/tmp/cvs-serv30180/scheme Modified Files: comp.scm Log Message: Removed "expr-" :) Index: comp.scm =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/comp.scm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** comp.scm 27 Oct 2003 16:33:24 -0000 1.5 --- comp.scm 27 Oct 2003 16:37:28 -0000 1.6 *************** *** 4,8 **** (require <lalr>) ! (define expr-parser (lalr-parser ;; --- token definitions --------------------------------------------- ;; --- 4,8 ---- (require <lalr>) ! (define parser (lalr-parser ;; --- token definitions --------------------------------------------- ;; *************** *** 49,53 **** '(uniform varying float tuple)) ! (define make-expr-lexer (lambda (tokens) (lambda () --- 49,53 ---- '(uniform varying float tuple)) ! (define make-lexer (lambda (tokens) (lambda () *************** *** 131,135 **** (define parse (lambda (filename) - (set! *exit?* #f) (letrec ((errorp (lambda args --- 131,134 ---- *************** *** 140,144 **** (let ((tokens (tokenize (read-file port)))) (if (not (null? tokens)) ! (expr-parser (make-expr-lexer tokens) errorp) #f))))) (let* ((port (open-input-file filename)) --- 139,143 ---- (let ((tokens (tokenize (read-file port)))) (if (not (null? tokens)) ! (parser (make-lexer tokens) errorp) #f))))) (let* ((port (open-input-file filename)) *************** *** 154,156 **** (begin (write (car code)) (newline) ! (display-code (cdr code))))) \ No newline at end of file --- 153,159 ---- (begin (write (car code)) (newline) ! (display-code (cdr code))))) ! ! ;; ---------------------------------------------------------------------- ;; ! ;; Code generator ;; ! ;; ---------------------------------------------------------------------- ;; |
From: <ma...@us...> - 2003-10-27 16:36:09
|
Update of /cvsroot/jrman/drafts/scheme In directory sc8-pr-cvs1:/tmp/cvs-serv29129/scheme Modified Files: comp.scm Log Message: Transformed "compiler" into "parser" Index: comp.scm =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/comp.scm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** comp.scm 27 Oct 2003 15:40:15 -0000 1.4 --- comp.scm 27 Oct 2003 16:33:24 -0000 1.5 *************** *** 1,7 **** - (require <lalr>) - ;; ---------------------------------------------------------------------- ;; ;; The LALR(1) parser ;; ;; ---------------------------------------------------------------------- ;; (define expr-parser (lalr-parser --- 1,7 ---- ;; ---------------------------------------------------------------------- ;; ;; The LALR(1) parser ;; ;; ---------------------------------------------------------------------- ;; + (require <lalr>) + (define expr-parser (lalr-parser *************** *** 14,17 **** --- 14,19 ---- ;; --- rules --------------------------------------------------------- ;; + (program (lines) : (append '(begin) $1)) + (lines (line) : `(,$1) (lines semicolon line) : (append $1 `(,$3))) *************** *** 125,133 **** ;; ---------------------------------------------------------------------- ;; ! ;; main ;; ;; ---------------------------------------------------------------------- ;; ! (define *exit?* #f) ! ! (define comp (lambda (filename) (set! *exit?* #f) --- 127,133 ---- ;; ---------------------------------------------------------------------- ;; ! ;; Generate parse tree ;; ;; ---------------------------------------------------------------------- ;; ! (define parse (lambda (filename) (set! *exit?* #f) *************** *** 136,154 **** (for-each display args) (newline) (loop))) - (display-code - (lambda (code) - (if (not (null? code)) - (begin (write (car code)) - (newline) - (display-code (cdr code)))))) (do-compile (lambda (port) (let ((tokens (tokenize (read-file port)))) (if (not (null? tokens)) ! (let ((v (expr-parser ! (make-expr-lexer tokens) ! errorp))) ! (display-code v))))))) ! (let ((port (open-input-file filename))) ! (do-compile port) ! (close-input-port port))))) \ No newline at end of file --- 136,156 ---- (for-each display args) (newline) (loop))) (do-compile (lambda (port) (let ((tokens (tokenize (read-file port)))) (if (not (null? tokens)) ! (expr-parser (make-expr-lexer tokens) errorp) ! #f))))) ! (let* ((port (open-input-file filename)) ! (tree (do-compile port))) ! (close-input-port port) ! tree)))) ! ! ;; ---------------------------------------------------------------------- ;; ! ;; Util ;; ! ;; ---------------------------------------------------------------------- ;; ! (define (display-code code) ! (if (not (null? code)) ! (begin (write (car code)) ! (newline) ! (display-code (cdr code))))) \ No newline at end of file |
From: <ma...@us...> - 2003-10-27 15:49:07
|
Update of /cvsroot/jrman/drafts/scheme In directory sc8-pr-cvs1:/tmp/cvs-serv16634/scheme Modified Files: comp.scm pru.comp Log Message: Added compiler declarations, improved code display. Index: comp.scm =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/comp.scm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** comp.scm 27 Oct 2003 15:26:40 -0000 1.3 --- comp.scm 27 Oct 2003 15:40:15 -0000 1.4 *************** *** 8,11 **** --- 8,12 ---- ;; --- token definitions --------------------------------------------- ;; (id num = lparen rparen semicolon + uniform varying float tuple (left: + -) (left: * /) *************** *** 16,23 **** (lines semicolon line) : (append $1 `(,$3))) ! (line (assign) : $1 ! (expr) : $1) (assign (id = expr) : `(set! ,$1 ,$3)) (expr (expr + expr) : `(+ ,$1 ,$3) --- 17,34 ---- (lines semicolon line) : (append $1 `(,$3))) ! (line (assign) : $1 ! (declaration) : $1 ! (expr) : $1) (assign (id = expr) : `(set! ,$1 ,$3)) + + (declaration (storage-class type id) : `(declare ,$3 ,$2 ,$1) + (type id) : `(declare ,$2 ,$1 uniform)) + + (storage-class (uniform) : 'uniform + (varying) : 'varying) + + (type (float) : 'float + (tuple) : 'tuple) (expr (expr + expr) : `(+ ,$1 ,$3) *************** *** 34,38 **** ;; ---------------------------------------------------------------------- ;; (define *keywords* ! '(declare uniform varying float tuple)) (define make-expr-lexer --- 45,49 ---- ;; ---------------------------------------------------------------------- ;; (define *keywords* ! '(uniform varying float tuple)) (define make-expr-lexer *************** *** 125,128 **** --- 136,145 ---- (for-each display args) (newline) (loop))) + (display-code + (lambda (code) + (if (not (null? code)) + (begin (write (car code)) + (newline) + (display-code (cdr code)))))) (do-compile (lambda (port) *************** *** 132,136 **** (make-expr-lexer tokens) errorp))) ! (write v) (newline))))))) (let ((port (open-input-file filename))) (do-compile port) --- 149,153 ---- (make-expr-lexer tokens) errorp))) ! (display-code v))))))) (let ((port (open-input-file filename))) (do-compile port) Index: pru.comp =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/pru.comp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pru.comp 27 Oct 2003 15:26:40 -0000 1.2 --- pru.comp 27 Oct 2003 15:40:15 -0000 1.3 *************** *** 1,2 **** --- 1,6 ---- + uniform float a; + varying tuple b; + float c; + tuple d; a = 2 * 6 + 3 * 5; b = a + 1; |
From: <ma...@us...> - 2003-10-27 15:27:21
|
Update of /cvsroot/jrman/drafts/scheme In directory sc8-pr-cvs1:/tmp/cvs-serv14061/scheme Modified Files: comp.scm pru.comp Log Message: Updated compiler to generate to parse to pseudo-scheme Index: comp.scm =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/comp.scm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** comp.scm 27 Oct 2003 06:39:19 -0000 1.2 --- comp.scm 27 Oct 2003 15:26:40 -0000 1.3 *************** *** 4,38 **** ;; The LALR(1) parser ;; ;; ---------------------------------------------------------------------- ;; ! (define (expr-parser lexer error-procedure) ! (letrec ((code ()) ! (emit-code ! (lambda (c) (set! code (cons c code))))) ! ((lalr-parser ! ;; --- token definitions --------------------------------------------- ;; ! (id num = lparen rparen semicolon ! (left: + -) ! (left: * /) ! (nonassoc: uminus)) ! ! ;; --- rules --------------------------------------------------------- ;; ! (lines (line) : () ! (line semicolon lines) : ()) ! ! (line (assign) : (emit-code $1) ! (expr) : (emit-code $1)) ! ! (assign (id = expr) : `(add-binding ',$1 ,$3)) ! ! (expr (expr + expr) : `(+ ,$1 ,$3) ! (expr - expr) : `(- ,$1 ,$3) ! (expr * expr) : `(* ,$1 ,$3) ! (expr / expr) : `(/ ,$1 ,$3) ! (- expr (prec: uminus)) : `(- ,$2) ! (id) : `(get-binding ',$1) ! (num) : $1 ! (lparen expr rparen) : $2)) ! lexer error-procedure) ! (reverse code))) ! ;; ---------------------------------------------------------------------- ;; --- 4,32 ---- ;; The LALR(1) parser ;; ;; ---------------------------------------------------------------------- ;; ! (define expr-parser ! (lalr-parser ! ;; --- token definitions --------------------------------------------- ;; ! (id num = lparen rparen semicolon ! (left: + -) ! (left: * /) ! (nonassoc: uminus)) ! ! ;; --- rules --------------------------------------------------------- ;; ! (lines (line) : `(,$1) ! (lines semicolon line) : (append $1 `(,$3))) ! ! (line (assign) : $1 ! (expr) : $1) ! ! (assign (id = expr) : `(set! ,$1 ,$3)) ! ! (expr (expr + expr) : `(+ ,$1 ,$3) ! (expr - expr) : `(- ,$1 ,$3) ! (expr * expr) : `(* ,$1 ,$3) ! (expr / expr) : `(/ ,$1 ,$3) ! (- expr (prec: uminus)) : `(- ,$2) ! (id) : $1 ! (num) : $1 ! (lparen expr rparen) : $2))) ;; ---------------------------------------------------------------------- ;; *************** *** 118,134 **** (switch l '())))) - ;; ---------------------------------------------------------------------- ;; - ;; Environment management ;; - ;; ---------------------------------------------------------------------- ;; - (define *env* '(($$ . 0))) - - (define (add-binding var val) - (set! *env* (cons (cons var val) *env*))) - - (define (get-binding var) - (let ((p (assq var *env*))) - (if p - (cdr p) - 0))) ;; ---------------------------------------------------------------------- ;; --- 112,115 ---- Index: pru.comp =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/pru.comp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pru.comp 27 Oct 2003 06:28:20 -0000 1.1 --- pru.comp 27 Oct 2003 15:26:40 -0000 1.2 *************** *** 1,3 **** a = 2 * 6 + 3 * 5; b = a + 1; ! b * 2 \ No newline at end of file --- 1,5 ---- a = 2 * 6 + 3 * 5; b = a + 1; ! c = a + b * 15; ! d = a + b + c; ! d \ No newline at end of file |
From: <ma...@us...> - 2003-10-27 06:41:20
|
Update of /cvsroot/jrman/drafts/scheme In directory sc8-pr-cvs1:/tmp/cvs-serv26418/scheme Modified Files: comp.scm Log Message: Small compiler improvements Index: comp.scm =================================================================== RCS file: /cvsroot/jrman/drafts/scheme/comp.scm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** comp.scm 27 Oct 2003 06:28:20 -0000 1.1 --- comp.scm 27 Oct 2003 06:39:19 -0000 1.2 *************** *** 1,8 **** (require <lalr>) ;; ---------------------------------------------------------------------- ;; ;; The LALR(1) parser ;; ;; ---------------------------------------------------------------------- ;; (define (expr-parser lexer error-procedure) ! (let ((code ())) ((lalr-parser ;; --- token definitions --------------------------------------------- ;; --- 1,11 ---- (require <lalr>) + ;; ---------------------------------------------------------------------- ;; ;; The LALR(1) parser ;; ;; ---------------------------------------------------------------------- ;; (define (expr-parser lexer error-procedure) ! (letrec ((code ()) ! (emit-code ! (lambda (c) (set! code (cons c code))))) ((lalr-parser ;; --- token definitions --------------------------------------------- ;; *************** *** 16,21 **** (line semicolon lines) : ()) ! (line (assign) : (set! code (append code (list $1))) ! (expr) : (set! code (append code (list $1)))) (assign (id = expr) : `(add-binding ',$1 ,$3)) --- 19,24 ---- (line semicolon lines) : ()) ! (line (assign) : (emit-code $1) ! (expr) : (emit-code $1)) (assign (id = expr) : `(add-binding ',$1 ,$3)) *************** *** 30,34 **** (lparen expr rparen) : $2)) lexer error-procedure) ! code)) --- 33,37 ---- (lparen expr rparen) : $2)) lexer error-procedure) ! (reverse code))) |
From: <ma...@us...> - 2003-10-27 06:28:41
|
Update of /cvsroot/jrman/drafts/scheme In directory sc8-pr-cvs1:/tmp/cvs-serv25104/scheme Added Files: comp.scm pru.comp Log Message: Started buiding experimental compiler. --- NEW FILE: comp.scm --- (require <lalr>) ;; ---------------------------------------------------------------------- ;; ;; The LALR(1) parser ;; ;; ---------------------------------------------------------------------- ;; (define (expr-parser lexer error-procedure) (let ((code ())) ((lalr-parser ;; --- token definitions --------------------------------------------- ;; (id num = lparen rparen semicolon (left: + -) (left: * /) (nonassoc: uminus)) ;; --- rules --------------------------------------------------------- ;; (lines (line) : () (line semicolon lines) : ()) (line (assign) : (set! code (append code (list $1))) (expr) : (set! code (append code (list $1)))) (assign (id = expr) : `(add-binding ',$1 ,$3)) (expr (expr + expr) : `(+ ,$1 ,$3) (expr - expr) : `(- ,$1 ,$3) (expr * expr) : `(* ,$1 ,$3) (expr / expr) : `(/ ,$1 ,$3) (- expr (prec: uminus)) : `(- ,$2) (id) : `(get-binding ',$1) (num) : $1 (lparen expr rparen) : $2)) lexer error-procedure) code)) ;; ---------------------------------------------------------------------- ;; ;; The lexer and reader ;; ;; ---------------------------------------------------------------------- ;; (define *keywords* '(declare uniform varying float tuple)) (define make-expr-lexer (lambda (tokens) (lambda () (if (null? tokens) '*eoi* (let ((p (car tokens))) (set! tokens (cdr tokens)) p))))) (define read-file (lambda (port) (let loop ((l '()) (c (read-char port))) (if (eof-object? c) (reverse l) (loop (cons c l) (read-char port)))))) (define tokenize (lambda (l) (letrec ((switch (lambda (l toks) (if (null? l) (reverse toks) (let ((c (car l))) (cond ((or (char=? c #\space) (char=? c #\tab) (char=? c #\newline)) (switch (cdr l) toks)) ((char=? c #\+) (switch (cdr l) (cons '+ toks))) ((char=? c #\-) (switch (cdr l) (cons '- toks))) ((char=? c #\*) (switch (cdr l) (cons '* toks))) ((char=? c #\/) (switch (cdr l) (cons '/ toks))) ((char=? c #\=) (switch (cdr l) (cons '= toks))) ((char=? c #\() (switch (cdr l) (cons 'lparen toks))) ((char=? c #\)) (switch (cdr l) (cons 'rparen toks))) ((char=? c #\;) (switch (cdr l) (cons 'semicolon toks))) ((char-numeric? c) (tokenize-number l toks)) ((char-alphabetic? c) (tokenize-id l toks)) (else (error "illegal character : " c))))))) (tokenize-id (lambda (l toks) (let loop ((r (list (car l))) (l (cdr l))) (if (or (null? l) (not (char-alphabetic? (car l)))) (switch l (cons (id-or-keyword (string->symbol (list->string (reverse r)))) toks)) (loop (cons (car l) r) (cdr l)))))) (id-or-keyword (lambda (sym) (if (memq sym *keywords*) sym (cons 'id sym)))) (tokenize-number (lambda (l toks) (let loop ((r (list (car l))) (l (cdr l))) (if (or (null? l) (not (char-numeric? (car l)))) (switch l (cons (cons 'num (string->number (list->string (reverse r)))) toks)) (loop (cons (car l) r) (cdr l))))))) (switch l '())))) ;; ---------------------------------------------------------------------- ;; ;; Environment management ;; ;; ---------------------------------------------------------------------- ;; (define *env* '(($$ . 0))) (define (add-binding var val) (set! *env* (cons (cons var val) *env*))) (define (get-binding var) (let ((p (assq var *env*))) (if p (cdr p) 0))) ;; ---------------------------------------------------------------------- ;; ;; main ;; ;; ---------------------------------------------------------------------- ;; (define *exit?* #f) (define comp (lambda (filename) (set! *exit?* #f) (letrec ((errorp (lambda args (for-each display args) (newline) (loop))) (do-compile (lambda (port) (let ((tokens (tokenize (read-file port)))) (if (not (null? tokens)) (let ((v (expr-parser (make-expr-lexer tokens) errorp))) (write v) (newline))))))) (let ((port (open-input-file filename))) (do-compile port) (close-input-port port))))) --- NEW FILE: pru.comp --- a = 2 * 6 + 3 * 5; b = a + 1; b * 2 |
From: <ma...@us...> - 2003-10-25 21:25:11
|
Update of /cvsroot/jrman/drafts/scheme In directory sc8-pr-cvs1:/tmp/cvs-serv25449/scheme Added Files: calc.scm lalr.scm Log Message: Added parser and example for compiler test. --- NEW FILE: calc.scm --- ;; ---------------------------------------------------------------------- ;; ;; The LALR(1) parser ;; ;; ---------------------------------------------------------------------- ;; (define expr-parser (lalr-parser ;; --- token definitions --------------------------------------------- ;; (id num = lparen rparen (left: + -) (left: * /) (nonassoc: uminus)) ;; --- rules --------------------------------------------------------- ;; (line (assign) : $1 (expr) : $1) (assign (id = expr) : (begin (add-binding $1 $3) $3)) (expr (expr + expr) : (+ $1 $3) (expr - expr) : (- $1 $3) (expr * expr) : (* $1 $3) (expr / expr) : (/ $1 $3) (- expr (prec: uminus)) : (- $2) (id) : (get-binding $1) (num) : $1 (lparen expr rparen) : $2))) ;; ---------------------------------------------------------------------- ;; ;; The lexer and reader ;; ;; ---------------------------------------------------------------------- ;; (define make-expr-lexer (lambda (tokens) (lambda () (if (null? tokens) '*eoi* (let ((p (car tokens))) (set! tokens (cdr tokens)) p))))) (define read-line (lambda (port) (let loop ((l '()) (c (read-char port))) (if (eof-object? c) (begin (set! *exit?* #t) (reverse l)) (if (char=? c #\newline) (reverse l) (loop (cons c l) (read-char port))))))) (define tokenize (lambda (l) (letrec ((switch (lambda (l toks) (if (null? l) (reverse toks) (let ((c (car l))) (cond ((or (char=? c #\space) (char=? c #\tab)) (switch (cdr l) toks)) ((char=? c #\+) (switch (cdr l) (cons '+ toks))) ((char=? c #\-) (switch (cdr l) (cons '- toks))) ((char=? c #\*) (switch (cdr l) (cons '* toks))) ((char=? c #\/) (switch (cdr l) (cons '/ toks))) ((char=? c #\=) (switch (cdr l) (cons '= toks))) ((char=? c #\() (switch (cdr l) (cons 'lparen toks))) ((char=? c #\)) (switch (cdr l) (cons 'rparen toks))) ((char-numeric? c) (tokenize-number l toks)) ((char-alphabetic? c) (tokenize-id l toks)) (else (error "illegal character : " c))))))) (tokenize-id (lambda (l toks) (let loop ((r (list (car l))) (l (cdr l))) (if (or (null? l) (not (char-alphabetic? (car l)))) (switch l (cons (cons 'id (string->symbol (list->string (reverse r)))) toks)) (loop (cons (car l) r) (cdr l)))))) (tokenize-number (lambda (l toks) (let loop ((r (list (car l))) (l (cdr l))) (if (or (null? l) (not (char-numeric? (car l)))) (switch l (cons (cons 'num (string->number (list->string (reverse r)))) toks)) (loop (cons (car l) r) (cdr l))))))) (switch l '())))) ;; ---------------------------------------------------------------------- ;; ;; Environment management ;; ;; ---------------------------------------------------------------------- ;; (define *env* '(($$ . 0))) (define (add-binding var val) (set! *env* (cons (cons var val) *env*))) (define (get-binding var) (let ((p (assq var *env*))) (if p (cdr p) 0))) ;; ---------------------------------------------------------------------- ;; ;; main ;; ;; ---------------------------------------------------------------------- ;; (define *exit?* #f) (define calc (lambda () (display "********************************") (newline) (display "* Mini calculator v0.1 *") (newline) (display "* *") (newline) (display "* Enter expressions followed *") (newline) (display "* by [RETURN] or [CTRL-D] to *") (newline) (display "* exit. *") (newline) (display "********************************") (newline) (set! *exit?* #f) (letrec ((errorp (lambda args (for-each display args) (newline) (loop))) (loop (lambda () (let ((tokens (tokenize (read-line (current-input-port))))) (if (not (null? tokens)) (let ((v (expr-parser (make-expr-lexer tokens) errorp))) (display "==> ") (display v) (newline))) (or *exit?* (loop)))))) (loop)))) --- NEW FILE: lalr.scm --- ;; ---------------------------------------------------------------------- ;; ;! @file "An Efficient and Portable Scheme LALR(1) Parser Generator" !; ;! @created "Mon Jan 22 15:42:32 1996" !; ;! @modified "Wed Sep 10 16:04:00 2003" !; ;! @version 2.0 !; ;; ---------------------------------------------------------------------- ;; ;! @copyright "Dominique Boucher" !; ;; Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. ;; ;; (for the Bison source code translated in Scheme) ;; ;; Copyright (C) 1996-2003 Dominique Boucher ;; ;; (for the translation in Scheme) ;; ;; ---------------------------------------------------------------------- ;; ;! @section (content "Content") !; ;! @list !; ;! @item @ref intro !; ;! @item @ref ports !; ;! @item @ref getting !; ;! @item @ref install !; ;! @item @ref decl !; [...1732 lines suppressed...] (if (eq? i '*eoi*) (errorp "PARSE ERROR : unexpected end of input ") (errorp "PARSE ERROR : unexpected token : " i))) ;; Shift current token on top of the stack ((>= act 0) (let ((stack (if (< (+ sp 2) (vector-length stack)) stack (___grow-stack stack)))) (vector-set! stack (+ sp 1) attr) (vector-set! stack (+ sp 2) act) (loop stack (+ sp 2) (lexerp)))) ;; Reduce by rule (- act) (else ((vector-ref ___rtable (- act)) stack sp ___gtable (lambda (stack sp) (loop stack sp input)))))))))))) code)) |