Skip to content

Commit

Permalink
Tool to remove extra spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
lucteo committed Jun 1, 2019
1 parent 6904360 commit e755d23
Show file tree
Hide file tree
Showing 125 changed files with 96 additions and 306 deletions.
6 changes: 0 additions & 6 deletions SparrowImplicitLib/check.spr
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,18 @@ fun ()(this: @Gen, sizeHint: UInt): ValueType = _generator(sizeHint)

fun isValid(this: @Gen): Bool = _generator isSet



concept GenType(x) \
if typeOf(x.ValueType) == Type \
&& typeOf(x.isValid) == Bool \
&& typeOf(x(0)) == x.ValueType


//! Arbitrary prototype
//fun arbitrary(t: Type): t Gen

//! Arbitrary definition for the integer types
fun arbitrary(t: Type): t Gen if Integer(#$t)
return mkGen(t, \_Impl.NumericGen(t).gen)


//! Configuration options for our check function
[initCtor]
datatype CheckConfig
Expand Down Expand Up @@ -170,7 +166,6 @@ fun frequency(gens: Range): typeOf((#$gens.RetType).v2) if FreqGenType(#$gens.Re
curAcc += fg.v1
return typeOf((#$gens.RetType).v2)()


fun randBetween(min, max: Integer): commonType(typeOf(min), typeOf(max))
using T = commonType(typeOf(min), typeOf(max))
using RAND_MAX = 0x7fffffff
Expand Down Expand Up @@ -260,7 +255,6 @@ package _Impl
res.isTrivial = _pred(res.value)
return res


[initCtor]
datatype ClassifierRange(rangeType, predType: Type) \
if typeOf((#$predType)((#$rangeType front).value)) == String
Expand Down
5 changes: 0 additions & 5 deletions SparrowImplicitLib/logic/lRef.spr
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ concept LRefType(x) if (
&& isValid(x.reset(#$x.ValueType))
)


//using logicDebug = 1
//using logicRefDebug = 1


// A logical reference that contains strings
using LStr = LRef(String)

Expand All @@ -40,7 +38,6 @@ fun ctor(this: @ScopeTracer, name: StringRef)
fun dtor(this: @ScopeTracer)
cout << '>>> ' << str << '\n'


/// A logical reference
///
/// A logical reference is in essence a shared pointer over an optional value.
Expand Down Expand Up @@ -76,7 +73,6 @@ fun ctor(this, other: @LRef)
[ct] if ( isValid(logicDebug) && isValid(logicRefDebug) )
cout << "copy ctor: " << this << "\n"


[protected]
fun dtor(this: @LRef)
[ct] if ( isValid(logicDebug) && isValid(logicRefDebug) )
Expand Down Expand Up @@ -181,7 +177,6 @@ package _Impl

fun mkBinaryOp(l, r: @ValWrapper, oper: Int ct) = BinaryOp(-@typeOf(l), -@typeOf(r), oper)(l, r)


fun mkPlusOp(l, r: @ValWrapper) = mkBinaryOp(l, r, _operPlus)
fun mkMinusOp(l, r: @ValWrapper) = mkBinaryOp(l, r, _operMinus)
fun mkMulOp(l, r: @ValWrapper) = mkBinaryOp(l, r, _operMul)
Expand Down
7 changes: 0 additions & 7 deletions SparrowImplicitLib/logic/predicates.spr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ fun isSet(this: @Predicate) = predObj.isSet()

fun ()(this: @Predicate): Bool = predObj()


/// Logic equality: equality test + inference
fun eq(l, r: @AnyType) = _mkEq(mkValOrRef(l), mkValOrRef(r))
fun /=/(l, r: @AnyType) = _mkEq(mkValOrRef(l), mkValOrRef(r))
Expand All @@ -42,8 +41,6 @@ using oper_precedence_=/ = oper_precedence_== + 1
//setOperPrecedence("/=/", getOperPrecedence("==") + 1)
//setOperPrecedence("=/", getOperPrecedence("==") + 1)



/// Logic Disjunction
fun ||(l, r: @PredicateType) = OrRelation(-@typeOf(l), -@typeOf(r))(l, r)

Expand All @@ -55,7 +52,6 @@ fun mkFalse = LFalse()
/// Relation that always returns true
fun mkTrue = LTrue()


datatype UnifyLR(leftType, rightType: Type) if ValWrapper(#$leftType) && ValWrapper(#$rightType)
using ValueType = Bool
using ValuePassType = Bool
Expand Down Expand Up @@ -139,7 +135,6 @@ fun ()(this: @UnifyLR): Bool

fun _mkEq(l, r: @ValWrapper) = UnifyLR(-@typeOf(l), -@typeOf(r))(l, r)


datatype OrRelation(leftPredicateType, rightPredicateType: Type)
using ValueType = Bool
using ValuePassType = Bool
Expand Down Expand Up @@ -225,8 +220,6 @@ fun ()(this: @AndRelation): Bool
return false
return false



datatype LFalse
;
fun ()(this: LFalse) = false
Expand Down
2 changes: 1 addition & 1 deletion SparrowImplicitLib/logic/prolog.spr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import time = time
[macro] fun compileProlog(sourceString: CompilerAstNode): CompilerAstNode
var sourceStr: meta.AstNode = sourceString
[ct] if ( (sourceString nodeKind) != meta.nkSparrowExpLiteral )
meta.report("compileProlog should take a string literal as argument", (sourceStr location));
meta.report("compileProlog should take a string literal as argument", (sourceStr location))
return CompilerAstNode()
else
sourceStr semanticCheck
Expand Down
3 changes: 1 addition & 2 deletions SparrowImplicitLib/logic/prologImpl/codeGen.spr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import nodes
import location
import ir
package meta
package meta
import meta.sparrowNodes, meta.featherNodes, meta.compiler;

[ct] fun genProlog(sps: @SparrowPrologSystem): meta.AstNode = Impl.genPrologSystem(sps)
Expand All @@ -12,7 +12,6 @@ package Impl

[ct] var nullNode: AstNode


[ct] fun genPrologSystem(sps: @SparrowPrologSystem): AstNode
var l = sps.loc
var resNodes: Vector(AstNode)
Expand Down
1 change: 0 additions & 1 deletion SparrowImplicitLib/logic/prologImpl/lType.spr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import meta = meta.compilerCore
fun isAtomOnly(this: LType): Bool = this._testBit(atom) && !this._testBit(number)
fun isNumberOnly(this: LType): Bool = this._testBit(number) && !this._testBit(atom)


fun setAtomOnly(this: @LType): Bool = this._setAlternativeBits(atom, number)
fun setNumberOnly(this: @LType): Bool = this._setAlternativeBits(number, atom)

Expand Down
2 changes: 0 additions & 2 deletions SparrowImplicitLib/logic/prologImpl/lexer.spr
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ fun _getNextToken(this: @Lexer): Token
this._consumeLineComment // Just drop all characters until the end of line
return this._getNextToken // Get the next token


if isAlnum(ch)
// Check for numbers, variables and string atoms
if isDigit(ch)
Expand Down Expand Up @@ -103,7 +102,6 @@ fun _getNextToken(this: @Lexer): Token
this._advanceSource
return Token(_curLocation, tkClause)


var errMsg: String = "Invalid character found while parsing Prolog code: "
errMsg.append(ch)
_errorReporter.raiseError(_curLocation, errMsg.asStringRef)
Expand Down
2 changes: 0 additions & 2 deletions SparrowImplicitLib/logic/prologImpl/parser.spr
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ concept TokenRange(x: Range) if -@(x.RetType) == Token
this._invalidToken(tok, String("atom, variable, number or antiquote"))
return ExpressionPtr()


fun _expectToken(this: @Parser, tok: @Token, expected: Int)
if tok.type != expected
this._invalidToken(tok, tokenTypeToString(expected))
Expand All @@ -253,5 +252,4 @@ concept TokenRange(x: Range) if -@(x.RetType) == Token
var msg: String = String("Invalid token found: ") + tokenTypeToString(tok.type) + String("; expected: ") + expected
this._errorReporter.raiseError(tok.loc, msg.asStringRef)


fun mkParser(lexer: @TokenRange, errorReporter: @AnyType) = Parser(-@typeOf(lexer), -@typeOf(errorReporter))(lexer, errorReporter)
1 change: 0 additions & 1 deletion SparrowImplicitLib/logic/prologImpl/token.spr
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ fun ctor(this: @Token, loc: @Location, type: Int, data: @String)
this.type ctor type
this.data ctor data


fun >>(this: @Token, os: @OutStream)
if type == tkEof
os << "<eof>"
Expand Down
2 changes: 0 additions & 2 deletions SparrowImplicitLib/logic/recurse.spr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ fun rec(pred, a1, a2, a3, a4, a5: @AnyType) \

fun _mkRecurse(predGenerator: @AnyType) = Recurse(-@typeOf(predGenerator))(predGenerator)


datatype Recurse(predGeneratorType: Type)
_relation: Predicate
_predGenerator: predGeneratorType
Expand All @@ -48,7 +47,6 @@ fun ()(this: @Recurse): Bool
cout << "Recurse.(): " << this << "\n"
return _relation()


fun >>(this: @Recurse, os: @OutStream)
os << "Recurse(this=" << mkStreamRefWrapper(this) \
<< ", fun=" << _relation
Expand Down
6 changes: 0 additions & 6 deletions SparrowImplicitLib/meta/compilerCore.spr
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[public] import meta.location
import std.contiguousMemoryRange


// Main types

/// Type representing a compilation context -- some information describing how
Expand All @@ -17,13 +16,11 @@ using AstNode = CompilerAstNode
/// A range of nodes (contiguously aligned in memory)
using AstNodeRange = ContiguousMemoryRange(AstNode)


// Evaluation modes
using modeUnspecified = 0
using modeRt = 1
using modeCt = 2


// Diagnostic

using diagInternal = 0
Expand Down Expand Up @@ -54,7 +51,6 @@ fun mkDiagnostic(type: Int, loc: Location, message: StringRef): Diagnostic
[native("$meta.raise")]
fun raise()


[ct]

// CompilationContext functions
Expand All @@ -70,7 +66,6 @@ fun mkDiagnostic(type: Int, loc: Location, message: StringRef): Diagnostic
[native("$meta.CompilationContext.sourceCode")]
fun sourceCode(ctx: CompilationContext): SourceCode


// AstType functions

/// Gets the kind of the given type
Expand All @@ -92,7 +87,6 @@ fun mkDiagnostic(type: Int, loc: Location, message: StringRef): Diagnostic
[native("$meta.AstType.canBeUsedAtRt")]
fun canBeUsedAtRt(t: AstType): Bool


// AstNode functions

/// Tests if the given node is null
Expand Down
2 changes: 0 additions & 2 deletions SparrowImplicitLib/meta/location.spr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ datatype SourceCode = @Byte
fun >>(s: @SourceCode, os: @OutStream)
os << mkStreamRefWrapper(s.data)


/// Type that holds the location information: a source code and a range of chars into it
datatype Location
sourceCode: SourceCode
Expand Down Expand Up @@ -44,7 +43,6 @@ fun mkLocation: Location
res.end = end
return res


/// Set the location to (1,1,1,1), the first character in a stream
fun setOne(l: @Location)
l.start.line = 1
Expand Down
2 changes: 0 additions & 2 deletions SparrowImplicitLib/par/atomic.spr
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ datatype Atomic(T: Type) if sizeOf(T) <= 8
return res
fun _baseAtomic(this: @Atomic): @Atomic(_UnderlyingType) = reinterpretCast(@Atomic(_UnderlyingType), this)


//! Compare the atomic value with the given comparand; if equal store 'newVal' and return true; if not equal returns false
[native("_Atomic_compareAndSwap32")] fun compareAndSwap(x: @AtomicInt, newVal, comparand: Int): Bool
[native("_Atomic_compareAndSwap64")] fun compareAndSwap(x: @AtomicLong, newVal, comparand: Long): Bool
Expand All @@ -94,7 +93,6 @@ fun compareAndSwap(x: @NonStdAtomicType, newVal, comparand: AnyType): Bool \
fun asAtomic(val: @AnyType): @Atomic(-@typeOf(val)) if sizeOf(val) == sizeOf(Atomic(-@typeOf(val)))
return reinterpretCast(@Atomic(-@typeOf(val)), val)


package _Impl
datatype AtomicTypeTraits(T: Type) if sizeOf(T) <= 4
using _UnderlyingType = Int
Expand Down
1 change: 0 additions & 1 deletion SparrowImplicitLib/par/config.spr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ fun >>(h: NativeThreadHandle, os: @OutStream)

using InvalidThreadHandle = NativeThreadHandle()


//! Get the number of available logical CPU cores for our process
//! This dictates how much parallelism we have to be exploit
fun getAvailableCoresNum(): UInt
Expand Down
1 change: 0 additions & 1 deletion SparrowImplicitLib/par/locks.spr
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ datatype ScopedTryLock(T: Type) if TryLockable(#$T)
_theLock: @LockType
_lockSucceeded: Bool


fun ctor(this: @ScopedTryLock, theLock: @this.LockType)
this._theLock := theLock
this._lockSucceeded = (_theLock tryLock)
Expand Down
2 changes: 0 additions & 2 deletions SparrowImplicitLib/par/parFor.spr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ concept Partitioner(x) \
&& isValid(x.partStart()) \
&& isValid(x.partition(valueOfType(x.RangeType), 0))


fun parFor(r: Range, f: AnyType) if isValid(f(r.front()))
Impl.parFor(r, f, DefaultPartitioner(typeOf(r))())

Expand Down Expand Up @@ -47,7 +46,6 @@ datatype BoundedRange(baseRangeType: Type)
using RetType = baseRangeType.RetType
using _RangeType = baseRangeType


fun ctor(this: @BoundedRange, r: @this._RangeType)
_baseRange ctor r
_count = (_baseRange rangeSize)
Expand Down
1 change: 0 additions & 1 deletion SparrowImplicitLib/par/tasks.spr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import tp = tasksImpl.taskPrefix
import tasksImpl.workerImpl
import schedulerIf = tasksImpl.schedulerIf


fun spawnRootAndWait(task: @TaskType)
[ct] if isValidAndTrue(tasksImpl.traceCalls) && isValid(cout << task)
cout << "spawnRootAndWait(" << task << ")" << endl
Expand Down
1 change: 0 additions & 1 deletion SparrowImplicitLib/par/tasksImpl/scheduler.spr
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ fun schedEnqueue(task: TaskPtr)
// Enqueue the task
taskWroker.taskSystem.globalQueue pushFront task


///////////////////////////////////////////////////////////////////////////////
// Task execution logic

Expand Down
1 change: 0 additions & 1 deletion SparrowImplicitLib/par/tasksImpl/taskQueue.spr
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ fun popBack(q: @TaskQueue): TaskPtr

return res


[initCtor] datatype TasksPrinter
_first: TaskPtr
list: @TaskQueue
Expand Down
2 changes: 0 additions & 2 deletions SparrowImplicitLib/par/tasksImpl/taskType.spr
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ concept TaskType(x) \
&& ( isValidAndTrue(typeOf(x prefix) == @TaskPrefix) \
|| isValidAndTrue(typeOf(x.prefix) == TaskPrefix) )


fun getPrefix(t: @TaskType): @TaskPrefix = t prefix if isValid(t prefix)
fun getPrefix(t: @TaskType): @TaskPrefix = t.prefix if isValid(t.prefix) && !isValid(t prefix)


2 changes: 0 additions & 2 deletions SparrowImplicitLib/par/tasksImpl/workerImpl.spr
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ fun worker(task: @TaskPrefix): @Worker = reinterpretCast(@Worker, task.worker.ge
fun waitingWorker(task: @TaskPrefix): @Worker = reinterpretCast(@Worker, task.waitingWorker.get())
fun setWaitingWorker(task: @TaskPrefix, w: @Worker) { task.waitingWorker = reinterpretCast(@Byte, w); }


////////////////////////////////////////////////////////////////////////////////
// TaskSystem datatype

Expand Down Expand Up @@ -160,7 +159,6 @@ fun onTaskAvailable(ts: @TaskSystem)
//! Get the number of currently available workers
fun numAvailableWorkers(ts: @TaskSystem): SizeType = (ts.workers size) - (ts.idleCounter numIdleWorkers)


////////////////////////////////////////////////////////////////////////////////
// InternalWorkerThread datatype

Expand Down
3 changes: 0 additions & 3 deletions SparrowImplicitLib/par/thread.spr
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ fun ctor(this: @ThreadId, h: NativeThreadHandle)
fun >>(tid: @ThreadId, os: @OutStream)
os << tid.id



datatype Thread
_handle: NativeThreadHandle

Expand Down Expand Up @@ -71,7 +69,6 @@ fun getId(t: Thread): ThreadId = ThreadId(t._handle)
//! Get the native handle of the given thread
fun getNativeHandle(t: Thread): NativeThreadHandle = t._handle


//! Get the current thread id
fun curThreadId: ThreadId = ThreadId(NativeThreadHandle())

Expand Down
Loading

0 comments on commit e755d23

Please sign in to comment.