Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
use the return value from "++" and "--" in the compiler now that it w…
…orks
  • Loading branch information
evanw committed Nov 8, 2015
1 parent e4999cd commit 344f6a2
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 82 deletions.
3 changes: 1 addition & 2 deletions examples/raytracer.sk
Expand Up @@ -27,8 +27,7 @@ def render(width int, height int, pixels Int32Array) {
var screenY = (y * 2.0 + 1 - height) / width
for x in 0..width {
var screenX = (x * 2.0 + 1 - width) / width
pixels[i] = scene.trace2D(screenX, -screenY).pack
i++
pixels[i++] = scene.trace2D(screenX, -screenY).pack
}
}
}
Expand Down
57 changes: 14 additions & 43 deletions skewc.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/core/node.sk
Expand Up @@ -576,8 +576,7 @@ namespace Skew {

namespace Node {
def _createID int {
_nextID++
return _nextID
return ++_nextID
}

var _nextID = 0
Expand Down
3 changes: 1 addition & 2 deletions src/core/symbol.sk
Expand Up @@ -250,8 +250,7 @@ namespace Skew {
var _nextID = 0

def _createID int {
_nextID++
return _nextID
return ++_nextID
}

def _substituteSymbols(node Node, symbols IntMap<Symbol>) {
Expand Down
12 changes: 4 additions & 8 deletions src/frontend/parser.sk
Expand Up @@ -1100,14 +1100,12 @@ namespace Skew.Parsing {
var start = 1 # Append long runs of unescaped characters using a single slice for speed
var i = 1
while i + 1 < text.count {
var c = text[i]
i++
var c = text[i++]
if c == '\\' {
var escape = i - 1
builder.append(text.slice(start, escape))
if i + 1 < text.count {
c = text[i]
i++
c = text[i++]
if c == 'n' {
builder.append("\n")
start = i
Expand All @@ -1134,11 +1132,9 @@ namespace Skew.Parsing {
}
else if c == 'x' {
if i + 1 < text.count {
var c0 = parseHexCharacter(text[i])
i++
var c0 = parseHexCharacter(text[i++])
if i + 1 < text.count {
var c1 = parseHexCharacter(text[i])
i++
var c1 = parseHexCharacter(text[i++])
if c0 != -1 && c1 != -1 {
builder.append(string.fromCodeUnit(c0 << 4 | c1))
start = i
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/token.sk
Expand Up @@ -68,8 +68,7 @@ namespace Skew {
}

# Compress tokens to eliminate unused null gaps
tokens[count] = token
count++
tokens[count++] = token

# Tokens that start with a greater than may need to be split
var tokenKind = token.kind
Expand Down
3 changes: 1 addition & 2 deletions src/middle/resolving.sk
Expand Up @@ -352,8 +352,7 @@ namespace Skew.Resolving {
var nextEnumValue = 0
for variable in symbol.variables {
if variable.kind == .VARIABLE_ENUM {
variable.value = Node.createInt(nextEnumValue).withType(symbol.resolvedType).withRange(variable.range)
nextEnumValue++
variable.value = Node.createInt(nextEnumValue++).withType(symbol.resolvedType).withRange(variable.range)
}
}
symbol.flags |= Symbol.IS_VALUE_TYPE
Expand Down
3 changes: 1 addition & 2 deletions src/middle/scope.sk
Expand Up @@ -102,8 +102,7 @@ namespace Skew {
var count = 0
var name = prefix
while isNameUsed(name) {
count++
name = prefix + count.toString
name = prefix + (++count).toString
}
reserveName(name, null)
return name
Expand Down
6 changes: 2 additions & 4 deletions src/middle/type.sk
Expand Up @@ -105,8 +105,7 @@ namespace Skew {
}

def _createID int {
_nextID++
return _nextID
return ++_nextID
}

var _nextID = 0
Expand All @@ -133,8 +132,7 @@ namespace Skew {

namespace Environment {
def _createID int {
_nextID++
return _nextID
return ++_nextID
}

var _nextID = 0
Expand Down
22 changes: 7 additions & 15 deletions src/middle/unicode.sk
Expand Up @@ -34,43 +34,35 @@ namespace Unicode {
if STRING_ENCODING == .UTF8 {
def nextCodePoint int {
if index >= stop { return -1 }
var a = value[index]
index++
var a = value[index++]
if a < 0xC0 { return a }
if index >= stop { return -1 }
var b = value[index]
index++
var b = value[index++]
if a < 0xE0 { return ((a & 0x1F) << 6) | (b & 0x3F) }
if index >= stop { return -1 }
var c = value[index]
index++
var c = value[index++]
if a < 0xF0 { return ((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F) }
if index >= stop { return -1 }
var d = value[index]
index++
var d = value[index++]
return ((a & 0x07) << 18) | ((b & 0x3F) << 12) | ((c & 0x3F) << 6) | (d & 0x3F)
}
}

else if STRING_ENCODING == .UTF16 {
def nextCodePoint int {
if index >= stop { return -1 }
var a = value[index]
index++
var a = value[index++]
if a < 0xD800 || a >= 0xDC00 { return a }
if index >= stop { return -1 }
var b = value[index]
index++
var b = value[index++]
return (a << 10) + b + (0x10000 - (0xD800 << 10) - 0xDC00)
}
}

else {
def nextCodePoint int {
if index >= stop { return -1 }
var c = value[index]
index++
return c
return value[index++]
}
}
}
Expand Down

0 comments on commit 344f6a2

Please sign in to comment.