Skip to content

Commit

Permalink
Hear! hear! a new minor version is born! The $:compile command hath
Browse files Browse the repository at this point in the history
come, and thou shalt try this code:

$:require("gfx
$gfx:clrscn(
$gfx:test(

Also, this is # 11 ^ 2.
  • Loading branch information
bluebear94 committed May 31, 2014
1 parent 72d40b5 commit 5eba25b
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 24 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ amw/

# swear data
git-pissed.html

# Ensime stuff
.ensime-2.11
.ensime_lucene/

# Annoying backup files
*~
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "Bag"

version := "0.6.2"

scalaVersion := "2.11.0"
scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
"org.scalatest" % "scalatest_2.10" % "2.1.3" % "test",
Expand Down
10 changes: 6 additions & 4 deletions build.sbt~
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name := "Bag"

version := "0.6.1"
version := "0.6.2"

scalaVersion := "2.11.0"
scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.0",
"org.scala-lang" % "scala-swing" % "2.11.0",
"org.scalatest" % "scalatest_2.10" % "2.1.3" % "test",
"org.scala-lang.modules" %% "scala-swing" % "1.0.1",
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.1"
)

lazy val root = project.in( file(".") ).dependsOn( assemblyPlugin )

lazy val assemblyPlugin = uri("git://github.com/ensime/ensime-sbt-cmd")
3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")

addSbtPlugin("org.scala-sbt.plugins" % "sbt-onejar" % "0.8")

lazy val root = project.in( file(".") ).dependsOn( assemblyPlugin )

lazy val assemblyPlugin = uri("git://github.com/ensime/ensime-sbt-cmd")
2 changes: 1 addition & 1 deletion project/plugins.sbt~
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")

addSbtPlugin("org.scala-sbt.plugins" % "sbt-onejar" % "0.8")

addSbtPlugin("org.ensime" % "ensime-sbt-cmd" % "0.1.3-SNAPSHOT")

15 changes: 12 additions & 3 deletions src/main/scala/cmdreader/Global.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,20 @@ object Global {
var currentAlias = "root"
@deprecated("Due to use of scala.math.BigInt instead.", "0.5.13")
val TWO = new BigInteger("2")
/*
* The major version number.
*/
val vM = 0
val vm = 6
val vr = 7
/*
* The minor version number.
*/
val vm = 7
/*
* The revision number.
*/
val vr = 0 // time for a new test image!
val vrr = "-alpha0"
val version = "v" + vM + "." + vm + "." + vr + vrr
val r: Random = new Random
var vigilant = true
}
}
28 changes: 28 additions & 0 deletions src/main/scala/cmdreader/std/Compile.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package cmdreader.std

import types._
import cmdreader._
import java.io._
import util._
import parse.ast._
import gui.Main
import rwvar._

class Compile extends Command {
def getName = "compile"
def isValidArg0(n: Int) = n == 1
def apply(args: Array[Type]) = {
val fname = args(0).toString
val a = PathNameConverter.aToOs(fname)._1
val addr = "amw/" + a.substring(0, a.length - 8) + "bag"
val srcAddr = new File(addr)
val srcReader = new FileReader(srcAddr)
// Can't get a fuckin' string from a file easily, ze
val srcPart = StringRetriever.getStringFrom(srcReader)
val src = s"\u03BB\n$srcPart\nEnd\u03BB"
val f = WholeParser.parse(src, Main.p)
VariableWriter.writeValToVarfile(VariableReader.readData(f.drop(6), 7, fname),
addr.substring(0, addr.length - 3) + "variable")
new TVoid
}
}
4 changes: 2 additions & 2 deletions src/main/scala/cmdreader/std/Loaderstd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class Loader {
"Disassembly", "OAndB", "OOrB", "OXorB", "Now", "Sub", "Rrbzo", "Abs", "Floor", "FPart", "OShl", "OShr",
"OMap", "Exp", "Ln", "Pi", "Expr", "FoldL", "FoldR", "OFilter", "HSort", "Str", "Len", "QSort", "MSort",
"Ribzpt", "OAug", "Help", "HAsk", "Clone", "ValCopy", "GetType", "OSeq", "Yield", "Stib", "Itsb", "Require",
"In", "Idx", "Isc", "Ixsc", "Cast", "Idxe", "Idxl", "Ixsce", "Ixscl").map(Global.liblist("std").loadCmd(_))
"In", "Idx", "Isc", "Ixsc", "Cast", "Idxe", "Idxl", "Ixsce", "Ixscl", "Compile").map(Global.liblist("std").loadCmd(_))
List("Sin", "Cos", "Tan").map({
s => List(s, s + "h", "A" + s, "A" + s + "h").map(Global.liblist("std").loadCmd(_))
})
}
}
}
8 changes: 4 additions & 4 deletions src/main/scala/gui/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object Main extends SimpleSwingApplication {
/**
* Standard monospace font.
*/
val mono = new Font("DejaVu Sans Mono", 0, 10)
val mono = new Font(Font.MONOSPACED, 0, 10)
/**
* A parser.
*/
Expand Down Expand Up @@ -64,8 +64,8 @@ object Main extends SimpleSwingApplication {
font = mono
editable = false
charWrap = true
text = "Welcome to Bag " + Global.version + ".\nEnter `$:help()' to get help.\n\n" +
(if (mono.getFamily != "DejaVu Sans Mono") "Please install the DejaVu fonts.\n" else "")
text = "Welcome to Bag " + Global.version + ".\nEnter `$:help()' to get help.\n\n"// +
//(if (mono.getFamily != "DejaVu Sans Mono") "Please install the DejaVu fonts.\n" else "")
tooltip = "The homescreen. Holds previous operations and console output."
lineWrap = true
}
Expand Down Expand Up @@ -253,4 +253,4 @@ class BufferedCanvas(d: Dimension) extends Panel { // sigh, I have to make one m
*/
class ExecutionThread extends Thread {
override def run = Main.runCode
}
}
43 changes: 34 additions & 9 deletions src/main/scala/util/GFX.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.awt._
import types._
import scala.collection.mutable.ArrayBuffer
import java.lang.reflect.Field
import cmdreader.Global

object GFX {
lazy val ds = Main.drawScn
Expand Down Expand Up @@ -57,14 +58,38 @@ object GFX {
val t = f.l(2)
new Font(z.toString, getIntOrChoke(o), getIntOrChoke(t))
}
def test() = {
setcol(Color.YELLOW)
circ(320, 240, 200, true)
setcol(Color.BLACK)
circ(200, 200, 20, true)
circ(440, 200, 20, true)
line(200, 300, 320, 320)
line(440, 300, 320, 320)
def test() = { // I had this planned since the birth of the gfx library. Mwahahahaha!
var prev = false
def nb = {
prev = if (Global.r.nextDouble > 0.8) Global.r.nextBoolean else !prev
prev
}
def ttf = 3 + Global.r.nextInt(3)
def kagome(x0: Int, x1: Int, y0: Int, y1: Int): Unit = {
def dot(x: Int, y: Int) = circ(x * 16, y * 16, 4, true)
val vert = nb
if (if (vert) Math.abs(x0 - x1) > ttf else Math.abs(y0 - y1) > ttf) {
val pct = Global.r.nextDouble * 0.4 + 0.3
val dx = x1 - x0
val dy = y1 - y0
val sp = (if (vert) x0 + pct * dx else y0 + pct * dy).toInt
if (vert) {
kagome(x0, sp, y0, y1)
kagome(sp + 1, x1, y0, y1)
for (i <- y0 to y1)
dot(sp, i)
} else {
kagome(x0, x1, y0, sp)
kagome(x0, x1, sp + 1, y1)
for (i <- x0 to x1)
dot(i, sp)
}
}
}
setcol(Color.GREEN)
kagome(0, 40, 0, 30)
setcol(Color.WHITE)
text("\u30ab\u30b4\u30e1\u30ab\u30b4\u30e1", 550, 20)
}
/**
* Method to return a color by name.
Expand Down Expand Up @@ -93,4 +118,4 @@ object GFX {
case _ => throw new IllegalArgumentException
}
}
}
}
21 changes: 21 additions & 0 deletions src/main/scala/util/StringRetriever.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package util

import java.io._
import scala.collection.mutable.StringBuilder

/*
* Retrieves a string from a Reader.
* @author bb94
*/
object StringRetriever {
def getStringFrom(r: Reader) = {
val cb = new StringBuilder
var cr = 0
while (cr != -1) {
cr = r.read
println(cr)
if (cr != -1) cb += cr.toChar
}
cb.result
}
}

0 comments on commit 5eba25b

Please sign in to comment.