diff --git a/SparrowImplicitLib/check.spr b/SparrowImplicitLib/check.spr index 94e725d1..e7786a8d 100644 --- a/SparrowImplicitLib/check.spr +++ b/SparrowImplicitLib/check.spr @@ -18,14 +18,11 @@ 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 @@ -33,7 +30,6 @@ concept GenType(x) \ 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 @@ -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 @@ -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 diff --git a/SparrowImplicitLib/logic/lRef.spr b/SparrowImplicitLib/logic/lRef.spr index 7d9cc758..ad3b4e4e 100644 --- a/SparrowImplicitLib/logic/lRef.spr +++ b/SparrowImplicitLib/logic/lRef.spr @@ -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) @@ -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. @@ -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) ) @@ -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) diff --git a/SparrowImplicitLib/logic/predicates.spr b/SparrowImplicitLib/logic/predicates.spr index b2bc9c1f..ce986462 100644 --- a/SparrowImplicitLib/logic/predicates.spr +++ b/SparrowImplicitLib/logic/predicates.spr @@ -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)) @@ -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) @@ -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 @@ -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 @@ -225,8 +220,6 @@ fun ()(this: @AndRelation): Bool return false return false - - datatype LFalse ; fun ()(this: LFalse) = false diff --git a/SparrowImplicitLib/logic/prolog.spr b/SparrowImplicitLib/logic/prolog.spr index ca150fd6..94b1ac26 100644 --- a/SparrowImplicitLib/logic/prolog.spr +++ b/SparrowImplicitLib/logic/prolog.spr @@ -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 diff --git a/SparrowImplicitLib/logic/prologImpl/codeGen.spr b/SparrowImplicitLib/logic/prologImpl/codeGen.spr index 94f0ca11..99d049e0 100644 --- a/SparrowImplicitLib/logic/prologImpl/codeGen.spr +++ b/SparrowImplicitLib/logic/prologImpl/codeGen.spr @@ -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) @@ -12,7 +12,6 @@ package Impl [ct] var nullNode: AstNode - [ct] fun genPrologSystem(sps: @SparrowPrologSystem): AstNode var l = sps.loc var resNodes: Vector(AstNode) diff --git a/SparrowImplicitLib/logic/prologImpl/lType.spr b/SparrowImplicitLib/logic/prologImpl/lType.spr index 83ecbea5..01041128 100644 --- a/SparrowImplicitLib/logic/prologImpl/lType.spr +++ b/SparrowImplicitLib/logic/prologImpl/lType.spr @@ -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) diff --git a/SparrowImplicitLib/logic/prologImpl/lexer.spr b/SparrowImplicitLib/logic/prologImpl/lexer.spr index f0217e60..3556d563 100644 --- a/SparrowImplicitLib/logic/prologImpl/lexer.spr +++ b/SparrowImplicitLib/logic/prologImpl/lexer.spr @@ -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) @@ -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) diff --git a/SparrowImplicitLib/logic/prologImpl/parser.spr b/SparrowImplicitLib/logic/prologImpl/parser.spr index a725921e..3200295e 100644 --- a/SparrowImplicitLib/logic/prologImpl/parser.spr +++ b/SparrowImplicitLib/logic/prologImpl/parser.spr @@ -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)) @@ -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) diff --git a/SparrowImplicitLib/logic/prologImpl/token.spr b/SparrowImplicitLib/logic/prologImpl/token.spr index 37fb5254..052a1e8f 100644 --- a/SparrowImplicitLib/logic/prologImpl/token.spr +++ b/SparrowImplicitLib/logic/prologImpl/token.spr @@ -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 << "" diff --git a/SparrowImplicitLib/logic/recurse.spr b/SparrowImplicitLib/logic/recurse.spr index 98e49873..e2731a9f 100644 --- a/SparrowImplicitLib/logic/recurse.spr +++ b/SparrowImplicitLib/logic/recurse.spr @@ -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 @@ -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 diff --git a/SparrowImplicitLib/meta/compilerCore.spr b/SparrowImplicitLib/meta/compilerCore.spr index ca97ab30..3162231e 100644 --- a/SparrowImplicitLib/meta/compilerCore.spr +++ b/SparrowImplicitLib/meta/compilerCore.spr @@ -1,7 +1,6 @@ [public] import meta.location import std.contiguousMemoryRange - // Main types /// Type representing a compilation context -- some information describing how @@ -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 @@ -54,7 +51,6 @@ fun mkDiagnostic(type: Int, loc: Location, message: StringRef): Diagnostic [native("$meta.raise")] fun raise() - [ct] // CompilationContext functions @@ -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 @@ -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 diff --git a/SparrowImplicitLib/meta/location.spr b/SparrowImplicitLib/meta/location.spr index 8ae95df9..342308ae 100644 --- a/SparrowImplicitLib/meta/location.spr +++ b/SparrowImplicitLib/meta/location.spr @@ -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 @@ -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 diff --git a/SparrowImplicitLib/par/atomic.spr b/SparrowImplicitLib/par/atomic.spr index 31fbdba4..2d43c50c 100644 --- a/SparrowImplicitLib/par/atomic.spr +++ b/SparrowImplicitLib/par/atomic.spr @@ -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 @@ -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 diff --git a/SparrowImplicitLib/par/config.spr b/SparrowImplicitLib/par/config.spr index 5fe4e528..5ecdb210 100644 --- a/SparrowImplicitLib/par/config.spr +++ b/SparrowImplicitLib/par/config.spr @@ -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 diff --git a/SparrowImplicitLib/par/locks.spr b/SparrowImplicitLib/par/locks.spr index 4c1e6814..bd635d56 100644 --- a/SparrowImplicitLib/par/locks.spr +++ b/SparrowImplicitLib/par/locks.spr @@ -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) diff --git a/SparrowImplicitLib/par/parFor.spr b/SparrowImplicitLib/par/parFor.spr index 211ba844..84ebb73a 100644 --- a/SparrowImplicitLib/par/parFor.spr +++ b/SparrowImplicitLib/par/parFor.spr @@ -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))()) @@ -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) diff --git a/SparrowImplicitLib/par/tasks.spr b/SparrowImplicitLib/par/tasks.spr index 808cfcaa..612c8f3f 100644 --- a/SparrowImplicitLib/par/tasks.spr +++ b/SparrowImplicitLib/par/tasks.spr @@ -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 diff --git a/SparrowImplicitLib/par/tasksImpl/scheduler.spr b/SparrowImplicitLib/par/tasksImpl/scheduler.spr index 8d5ff810..f97c09c7 100644 --- a/SparrowImplicitLib/par/tasksImpl/scheduler.spr +++ b/SparrowImplicitLib/par/tasksImpl/scheduler.spr @@ -85,7 +85,6 @@ fun schedEnqueue(task: TaskPtr) // Enqueue the task taskWroker.taskSystem.globalQueue pushFront task - /////////////////////////////////////////////////////////////////////////////// // Task execution logic diff --git a/SparrowImplicitLib/par/tasksImpl/taskQueue.spr b/SparrowImplicitLib/par/tasksImpl/taskQueue.spr index 6a12a6e7..10357827 100644 --- a/SparrowImplicitLib/par/tasksImpl/taskQueue.spr +++ b/SparrowImplicitLib/par/tasksImpl/taskQueue.spr @@ -86,7 +86,6 @@ fun popBack(q: @TaskQueue): TaskPtr return res - [initCtor] datatype TasksPrinter _first: TaskPtr list: @TaskQueue diff --git a/SparrowImplicitLib/par/tasksImpl/taskType.spr b/SparrowImplicitLib/par/tasksImpl/taskType.spr index 2fbd1385..cf553162 100644 --- a/SparrowImplicitLib/par/tasksImpl/taskType.spr +++ b/SparrowImplicitLib/par/tasksImpl/taskType.spr @@ -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) - diff --git a/SparrowImplicitLib/par/tasksImpl/workerImpl.spr b/SparrowImplicitLib/par/tasksImpl/workerImpl.spr index 284914a7..0cd0b000 100644 --- a/SparrowImplicitLib/par/tasksImpl/workerImpl.spr +++ b/SparrowImplicitLib/par/tasksImpl/workerImpl.spr @@ -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 @@ -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 diff --git a/SparrowImplicitLib/par/thread.spr b/SparrowImplicitLib/par/thread.spr index 0a036437..b8991a2f 100644 --- a/SparrowImplicitLib/par/thread.spr +++ b/SparrowImplicitLib/par/thread.spr @@ -16,8 +16,6 @@ fun ctor(this: @ThreadId, h: NativeThreadHandle) fun >>(tid: @ThreadId, os: @OutStream) os << tid.id - - datatype Thread _handle: NativeThreadHandle @@ -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()) diff --git a/SparrowImplicitLib/sprCore/basicDecls.spr b/SparrowImplicitLib/sprCore/basicDecls.spr index 96cbb566..45b4fe20 100644 --- a/SparrowImplicitLib/sprCore/basicDecls.spr +++ b/SparrowImplicitLib/sprCore/basicDecls.spr @@ -306,7 +306,6 @@ concept Number(x) \ || FloatingPointNumber(x) \ - datatype NumericLimits(t: Type) if t == Byte using maxValue = Byte(0x7f) using minValue = Byte(0x80) @@ -380,7 +379,6 @@ using oper_precedence_>> = 50 using oper_assoc_= = -1 using oper_assoc_:= = -1 - //////////////////////////////////////////////////////////////////////////////// /// operations on Bool & Char /// @@ -400,7 +398,6 @@ using oper_assoc_:= = -1 [native("_Char_opLE")] fun <= (x, y: Char): Bool [native("_Char_opGE")] fun >= (x, y: Char): Bool - //////////////////////////////////////////////////////////////////////////////// /// Numeric operations /// @@ -616,10 +613,6 @@ using oper_assoc_:= = -1 fun post_--(n: @SizeType): SizeType { var old = n; n-=SizeType(1); return old; } fun post_--(n: @DiffType): DiffType { var old = n; n-=DiffType(1); return old; } - - - - //////////////////////////////////////////////////////////////////////////////// /// StringRef /// @@ -741,7 +734,6 @@ fun construct() [native("$injectBackendCode")] fun injectBackendCode(code: StringRef) [native("$injectBackendCodeCt")] fun injectBackendCodeCt(code: StringRef) - /// Type used to represent an untyped pointer [bitcopiable] datatype UntypedPtr = @Byte @@ -805,7 +797,6 @@ concept AnyType(x) // Always true fun valueOfType(t: Type): t fun #$(t: Type): t - //////////////////////////////////////////////////////////////////////////////// /// Some low-level helper functions /// @@ -827,7 +818,6 @@ fun #$(t: Type): t [native("system")] fun systemNative(x: @Char) [native("sleep")] fun sleep(x: Int) - //////////////////////////////////////////////////////////////////////////////// /// Range is such a fundamental concept /// diff --git a/SparrowImplicitLib/sprCore/functionPtr.spr b/SparrowImplicitLib/sprCore/functionPtr.spr index 9d9e1b47..57dbb3fc 100644 --- a/SparrowImplicitLib/sprCore/functionPtr.spr +++ b/SparrowImplicitLib/sprCore/functionPtr.spr @@ -174,7 +174,6 @@ package _Impl11 [native("$funptr")] fun _doCall(this: @FunctionPtr11, p1: this.T1, p2: this.T2, p3: this.T3, p4: this.T4, p5: this.T5, p6: this.T6, p7: this.T7, p8: this.T8, p9: this.T9, p10: this.T10, p11: this.T11): ResT fun ()(this: @FunctionPtr11, p1: this.T1, p2: this.T2, p3: this.T3, p4: this.T4, p5: this.T5, p6: this.T6, p7: this.T7, p8: this.T8, p9: this.T9, p10: this.T10, p11: this.T11): ResT = this._doCall(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) - package _Impl12 datatype FunctionPtr12(resT, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12: Type) using arity = 12 @@ -265,7 +264,6 @@ package _Impl15 [native("$funptr")] fun _doCall(this: @FunctionPtr15, p1: this.T1, p2: this.T2, p3: this.T3, p4: this.T4, p5: this.T5, p6: this.T6, p7: this.T7, p8: this.T8, p9: this.T9, p10: this.T10, p11: this.T11, p12: this.T12, p13: this.T13, p14: this.T14, p15: this.T15): ResT fun ()(this: @FunctionPtr15, p1: this.T1, p2: this.T2, p3: this.T3, p4: this.T4, p5: this.T5, p6: this.T6, p7: this.T7, p8: this.T8, p9: this.T9, p10: this.T10, p11: this.T11, p12: this.T12, p13: this.T13, p14: this.T14, p15: this.T15): ResT = this._doCall(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) - using FunctionPtr = _Impl0.FunctionPtr0 using FunctionPtr = _Impl1.FunctionPtr1 using FunctionPtr = _Impl2.FunctionPtr2 diff --git a/SparrowImplicitLib/sprCore/streamBasic.spr b/SparrowImplicitLib/sprCore/streamBasic.spr index be49dace..481de04c 100644 --- a/SparrowImplicitLib/sprCore/streamBasic.spr +++ b/SparrowImplicitLib/sprCore/streamBasic.spr @@ -20,7 +20,6 @@ fun << (s: @OutStream, x: @AnyType): typeOf(s) if !isValid(x.>>(s)) && isValid(s s.<<<(x) return s - var endl: EndLineHelperClass var flush: FlushHelperClass diff --git a/SparrowImplicitLib/std/array.spr b/SparrowImplicitLib/std/array.spr index 2a5ae26e..70226da0 100644 --- a/SparrowImplicitLib/std/array.spr +++ b/SparrowImplicitLib/std/array.spr @@ -148,4 +148,3 @@ datatype Array(valueType: Type) cout << " begin: " << mkStreamRefWrapper(_begin.bytePtr) << endl cout << " end: " << mkStreamRefWrapper(_end.bytePtr) << endl - diff --git a/SparrowImplicitLib/std/defaultHashFunction.spr b/SparrowImplicitLib/std/defaultHashFunction.spr index 9633e0a6..01e81d88 100644 --- a/SparrowImplicitLib/std/defaultHashFunction.spr +++ b/SparrowImplicitLib/std/defaultHashFunction.spr @@ -16,7 +16,6 @@ fun defaultHash(arg: Integer) = SizeType(arg) fun defaultHash(arg: StringRef) = _doHash(arg, _seed) fun defaultHash(arg: @String) = _doHash(arg.asStringRef(), _seed) - using _seed = 0xfadef00d /// FNV hash generator diff --git a/SparrowImplicitLib/std/function.spr b/SparrowImplicitLib/std/function.spr index 04667632..cb5037df 100644 --- a/SparrowImplicitLib/std/function.spr +++ b/SparrowImplicitLib/std/function.spr @@ -116,8 +116,6 @@ package _Impl2 fun >>(this: @Function2, os: @OutStream) os << _data - - package _Impl3 datatype Function3(resT, t1, t2, t3: Type) using arity = 3 diff --git a/SparrowImplicitLib/std/hashTable.spr b/SparrowImplicitLib/std/hashTable.spr index c134e150..334e19ad 100644 --- a/SparrowImplicitLib/std/hashTable.spr +++ b/SparrowImplicitLib/std/hashTable.spr @@ -19,7 +19,6 @@ datatype HashTable(keyType, valueType, valueToKeyType, traitsType: Type) using _BucketsType = Array(_NodePtr) using _TraitsType = traitsType - _buckets: _BucketsType _guard: _MyGuardNode _numElements: SizeType @@ -312,7 +311,6 @@ fun >> (this: @_Node, os: @OutStream) datatype _GuardNode(valueType: Type) next: Ptr(_Node(valueType)) - [initCtor] datatype _HashRange(valueType: Type) using RetType = @valueType @@ -325,7 +323,6 @@ datatype _HashRange(valueType: Type) fun front(this: _HashRange): this.RetType = _startElem.get().data fun popFront(this: @_HashRange) { _startElem = _startElem.get().next; } - var _bucketCounts: StaticArray(SizeType, 31) using _loadFactor = 1 diff --git a/SparrowImplicitLib/std/list.spr b/SparrowImplicitLib/std/list.spr index e48903e7..bb7c6aaa 100644 --- a/SparrowImplicitLib/std/list.spr +++ b/SparrowImplicitLib/std/list.spr @@ -436,7 +436,6 @@ datatype _NodeType(valueType: Type) fun popFront(this: @_ListRange) { _begin = _begin.value().next } fun popBack(this: @_ListRange) { _end = _end.value().prev } - fun >>(this: _ListRange, os: @OutStream) if isValid(os << #$valueType) var first = true var p = _begin diff --git a/SparrowImplicitLib/std/optional.spr b/SparrowImplicitLib/std/optional.spr index f42e7740..fe463640 100644 --- a/SparrowImplicitLib/std/optional.spr +++ b/SparrowImplicitLib/std/optional.spr @@ -60,4 +60,3 @@ fun ctor(this: @Optional, val: @this.ValueType) else os << "Optional(none)" - diff --git a/SparrowImplicitLib/std/rMath.spr b/SparrowImplicitLib/std/rMath.spr index cc312abc..4a8b4844 100644 --- a/SparrowImplicitLib/std/rMath.spr +++ b/SparrowImplicitLib/std/rMath.spr @@ -3,7 +3,6 @@ module std.rMath import math(sqrt) import algorithms(foldLeft) - fun sqr n = n*n fun sum(r: Range) = foldLeft(r, (fun x,y = x+y), r.RetType(0)) diff --git a/SparrowImplicitLib/std/ranges.spr b/SparrowImplicitLib/std/ranges.spr index d97c301b..4441706c 100644 --- a/SparrowImplicitLib/std/ranges.spr +++ b/SparrowImplicitLib/std/ranges.spr @@ -49,7 +49,6 @@ fun pre_*(r: @Range): r.RetType = r.front // Call operator on range == range.front //fun post_()(r: @Range) = r.front - /////////////////////////////////////////////////////////////////////////////// // General range operations // @@ -97,7 +96,6 @@ fun post_..(start: Number) = NumericRangeInc(typeOf(start))(start, NumericLimits fun ../(range: Range, step: Number) = NumericRangeWithStep(range.RetType)(range, step) - /////////////////////////////////////////////////////////////////////////////// // Range constructors // @@ -166,7 +164,6 @@ fun zip(range1, range2: Range) = zip(range1, range2, MakePair(-@typeOf(range1.fr /// Scans left a range for the given functor and initial accumulator value fun scanLeft(acc: AnyType, range: Range, function: AnyType) = ScanLeftRange(typeOf(acc), typeOf(range), typeOf(function))(acc, range, function) - /////////////////////////////////////////////////////////////////////////////// // Classes that implement ranges // @@ -542,7 +539,6 @@ datatype ValuesRange(contType: Type) if isValid((#$contType)(1)) using RetType = contType.ValueType - [protected] fun isEmpty(this: @ValuesRange) = _idx >= _values.size fun front(this: @ValuesRange): RetType = _values(_idx) diff --git a/SparrowImplicitLib/std/rawPtr.spr b/SparrowImplicitLib/std/rawPtr.spr index c33571a3..45e2c6b2 100644 --- a/SparrowImplicitLib/std/rawPtr.spr +++ b/SparrowImplicitLib/std/rawPtr.spr @@ -35,7 +35,6 @@ fun ctor(this: @RawPtr, byteRef: @Byte) if this.ValueType != Byte _ptr := other._ptr other._ptr := t - fun >>(this: RawPtr, os: @OutStream) os << "RawPtr(" << mkStreamRefWrapper(this.bytePtr) << ")" diff --git a/SparrowImplicitLib/std/scopedPtr.spr b/SparrowImplicitLib/std/scopedPtr.spr index 679e82b3..8be7412f 100644 --- a/SparrowImplicitLib/std/scopedPtr.spr +++ b/SparrowImplicitLib/std/scopedPtr.spr @@ -16,7 +16,6 @@ datatype ScopedPtr(type: Type) fun isNull(this: ScopedPtr) = _ref === null fun isSet(this: ScopedPtr) = _ref !== null - fun reset(this: @ScopedPtr) { delete(_ref); _ref := null } fun reset(this: @ScopedPtr, ref: @this.ValueType) { delete(this._ref); this._ref := ref } diff --git a/SparrowImplicitLib/std/staticArray.spr b/SparrowImplicitLib/std/staticArray.spr index ac50ce5a..3a13e06a 100644 --- a/SparrowImplicitLib/std/staticArray.spr +++ b/SparrowImplicitLib/std/staticArray.spr @@ -151,7 +151,6 @@ fun mkValues(v0,v1,v2,v3,v4,v5,v6,v7: AnyType) = StaticArray(typeOf(v0), 8)(v0,v fun mkValues(v0,v1,v2,v3,v4,v5,v6,v7,v8: AnyType) = StaticArray(typeOf(v0), 9)(v0,v1,v2,v3,v4,v5,v6,v7,v8) fun mkValues(v0,v1,v2,v3,v4,v5,v6,v7,v8,v9: AnyType) = StaticArray(typeOf(v0), 10)(v0,v1,v2,v3,v4,v5,v6,v7,v8,v9) - [ctGeneric] fun StaticArray2d(baseType: Type, d1, d2: SizeType ct) \ = StaticArray(StaticArray(baseType, d2), d1) diff --git a/SparrowImplicitLib/std/string.spr b/SparrowImplicitLib/std/string.spr index f92e7845..99e0fb58 100644 --- a/SparrowImplicitLib/std/string.spr +++ b/SparrowImplicitLib/std/string.spr @@ -84,7 +84,6 @@ fun ctor(this: @String, range: Range) if typeOf(range) != String fun asStringRef(this: @String) = StringRef(_begin.bytePtr, _end.bytePtr) - fun size(this: @String): SizeType = _end.diff(_begin) fun isEmpty(this: @String) = _begin == _end fun capacity(this: @String): SizeType = _endOfStore.diff(_begin) @@ -257,7 +256,6 @@ fun + (x: String, y: StringRef): String // return res - fun intToString(x: Int): String var buf: static_buffer(12) _intToCString(x, reinterpretCast(@Char, buf)) diff --git a/SparrowImplicitLib/std/vector.spr b/SparrowImplicitLib/std/vector.spr index 0c6c3974..bbd3d50b 100644 --- a/SparrowImplicitLib/std/vector.spr +++ b/SparrowImplicitLib/std/vector.spr @@ -118,7 +118,6 @@ datatype Vector(valueType: Type) if n <= curCapacity return - if n < _initialCapacity n = _initialCapacity if n < _growthFactor*curCapacity diff --git a/tests/Basic/Auto.spr b/tests/Basic/Auto.spr index c34a49fc..a6ecbccc 100644 --- a/tests/Basic/Auto.spr +++ b/tests/Basic/Auto.spr @@ -22,7 +22,6 @@ fun f2(x: @AnyType) if typeOf(x) == (Int@) f2(a) writeLn(a) - /*<<>>*/ - diff --git a/tests/Basic/Generics.spr b/tests/Basic/Generics.spr index 5284db58..0afa67e5 100644 --- a/tests/Basic/Generics.spr +++ b/tests/Basic/Generics.spr @@ -31,7 +31,6 @@ fun print(this: @MyVector) write(' ') writeLn(end) - fun valSize(x: AnyType): SizeType return sizeOf(x) @@ -67,7 +66,6 @@ fun valSize(x: AnyType): SizeType writeLn(valSize(v1)) writeLn(valSize(v2)) - /*<<>>*/ - fun test2 var x = 10 var y = 11 diff --git a/tests/Basic2/LogicalAndOr.spr b/tests/Basic2/LogicalAndOr.spr index b9075f67..0d00d4f2 100644 --- a/tests/Basic2/LogicalAndOr.spr +++ b/tests/Basic2/LogicalAndOr.spr @@ -59,7 +59,6 @@ fun test1 cout << (f || f || t) << endl cout << (f || f || f) << endl - /*<<=2 && 1>=2) - /*<<>>*/ \ No newline at end of file diff --git a/tests/Bugs/SpecializationOnCt.spr b/tests/Bugs/SpecializationOnCt.spr index 537fed83..ee17d137 100644 --- a/tests/Bugs/SpecializationOnCt.spr +++ b/tests/Bugs/SpecializationOnCt.spr @@ -19,8 +19,6 @@ fun regexMatch(re: StringRef ct, str: StringRef): Bool cout << "CT: regexMatch(" << re << ", " << str << ")\n" return false - - fun sprMain var n = 5 diff --git a/tests/Bugs/TwiceFor.spr b/tests/Bugs/TwiceFor.spr index 757d4136..ee0bd291 100644 --- a/tests/Bugs/TwiceFor.spr +++ b/tests/Bugs/TwiceFor.spr @@ -11,7 +11,6 @@ fun sprMain cout << ' ' << val cout << endl - /*<<>>*/ - fun test10 var x = 3 var y = 4 @@ -207,7 +206,6 @@ fun test10 7 >>>*/ - fun test11 var x = 3 var y = 4 diff --git a/tests/Frontend/PrefixPostfix.spr b/tests/Frontend/PrefixPostfix.spr index c6cadeac..5395aef2 100644 --- a/tests/Frontend/PrefixPostfix.spr +++ b/tests/Frontend/PrefixPostfix.spr @@ -7,7 +7,6 @@ fun ---(x: @Int): @Int x -= 1 return x - fun pre_+++(x: @Int): @Int x += 1 return x diff --git a/tests/Frontend/parserTest.spr b/tests/Frontend/parserTest.spr index 50b36d02..e571e0f7 100644 --- a/tests/Frontend/parserTest.spr +++ b/tests/Frontend/parserTest.spr @@ -141,7 +141,6 @@ fun mkContinueStmt(this: @MyAstBuilder, loc: @Location) \ fun mkReturnStmt(this: @MyAstBuilder, loc: @Location, expr: Node) \ = createNode(loc, "return", repeat(expr, 1)) - fun sprMain if programArgs.size() < 2 return diff --git a/tests/Imports/ImportInTheMiddle.spr b/tests/Imports/ImportInTheMiddle.spr index c66c355d..431baebc 100644 --- a/tests/Imports/ImportInTheMiddle.spr +++ b/tests/Imports/ImportInTheMiddle.spr @@ -1,13 +1,13 @@ //!! -t "../Basic/SparrowImplicitLib.spr" -fno-main -package Foo1 - fun test1 +package Foo1 + fun test1 Foo2.a = 1 Foo2.b = 2 Foo2.c = 3 Foo2.d = 4 -package Foo2 +package Foo2 import HeaderD import HeaderC import HeaderB diff --git a/tests/Logic/FibOptTest.spr b/tests/Logic/FibOptTest.spr index a3f9709e..8c835a6f 100644 --- a/tests/Logic/FibOptTest.spr +++ b/tests/Logic/FibOptTest.spr @@ -1,7 +1,6 @@ //!! import logic.prologFrontend - fun fib_native(p_1: Int, p_2: @Int): Bool var l2_X2: Int = Uninitialized() var l2_Y2: Int = Uninitialized() diff --git a/tests/Logic/FibPrologErr.spr b/tests/Logic/FibPrologErr.spr index 0c23b24f..cae9d08f 100644 --- a/tests/Logic/FibPrologErr.spr +++ b/tests/Logic/FibPrologErr.spr @@ -13,7 +13,6 @@ compileProlog(" fib(sun, earth). %% ERROR ") - fun sprMain if ( programArgs.size() < 2 ) return diff --git a/tests/Logic/LogicTest.spr b/tests/Logic/LogicTest.spr index 4eabf394..aa17347f 100644 --- a/tests/Logic/LogicTest.spr +++ b/tests/Logic/LogicTest.spr @@ -3,7 +3,6 @@ import logic.predicates //import assert; import os = os - fun male(x: @LStr) = x /=/ "castor" || x /=/ "zeus" fun female(x: @LStr) = x /=/ "leda" || x /=/ "clytaemnestra" @@ -14,7 +13,6 @@ fun parents(father, mother, child: LRef(String)) \ = father /=/ "zeus" && mother /=/ "leda" && child /=/ "castor" \ || father /=/ "zeus" && mother /=/ "leda" && child /=/ "clytaemnestra" - fun sprMain if ( programArgs.size() < 2 ) return @@ -85,7 +83,6 @@ Found person: leda Found person: clytaemnestra >>>*/ - fun test5 var father, mother, child: LStr var pred = parents(father, mother, child) diff --git a/tests/Logic/PrologParserTest.spr b/tests/Logic/PrologParserTest.spr index fc999941..7756f9f1 100644 --- a/tests/Logic/PrologParserTest.spr +++ b/tests/Logic/PrologParserTest.spr @@ -79,8 +79,6 @@ logic.compileProlog(" ancestor(A, C) :- children(C, P), ancestor(A, P). }> - - fun sprMain if ( programArgs.size() < 2 ) return diff --git a/tests/Logic/Solar.spr b/tests/Logic/Solar.spr index f98a8f53..4d98c55c 100644 --- a/tests/Logic/Solar.spr +++ b/tests/Logic/Solar.spr @@ -2,7 +2,6 @@ import logic.predicates //import assert; - fun orbits(a, b: @LStr) = ( a /=/ "Mercury" && b /=/ "Sun" || a /=/ "Venus" && b /=/ "Sun" diff --git a/tests/Par/ParForTest.spr b/tests/Par/ParForTest.spr index d00696c0..0d94d5cc 100644 --- a/tests/Par/ParForTest.spr +++ b/tests/Par/ParForTest.spr @@ -9,7 +9,6 @@ import std.compilerInfo import par.atomic import test - var counter: Int Atomic var outOfOrderCount: Int Atomic diff --git a/tests/Par/TaskTest.spr b/tests/Par/TaskTest.spr index b451b117..0d42c1d4 100644 --- a/tests/Par/TaskTest.spr +++ b/tests/Par/TaskTest.spr @@ -180,7 +180,6 @@ Final result: fib(30)=832040 Final result: fib(30)=832040 >>>*/ - /*-<<>>*/ diff --git a/tests/Par/ThreadTest.spr b/tests/Par/ThreadTest.spr index eee4f2ce..2043378f 100644 --- a/tests/Par/ThreadTest.spr +++ b/tests/Par/ThreadTest.spr @@ -9,7 +9,6 @@ import std.compilerInfo import std.vector import std.string - fun sprMain if programArgs.size() < 2 return diff --git a/tests/Par/TlsTest.spr b/tests/Par/TlsTest.spr index 0f3f4584..118e0785 100644 --- a/tests/Par/TlsTest.spr +++ b/tests/Par/TlsTest.spr @@ -58,7 +58,6 @@ import std.compilerInfo t.get join t.release - fun sprMain if programArgs.size() < 4 return diff --git a/tests/PerfTests/FibRanges/fib_op.spr b/tests/PerfTests/FibRanges/fib_op.spr index a9cbcf1f..4897633d 100644 --- a/tests/PerfTests/FibRanges/fib_op.spr +++ b/tests/PerfTests/FibRanges/fib_op.spr @@ -4,14 +4,13 @@ import std.algorithms import std.rMath import std.tuple -fun fib(n: Int): Int +fun fib(n: Int): Int var p: Int*Int = 0 ~ 1 // Last 2 entries for i = 0..n p = p.v2 ~ (p.v1 + p.v2) return p.v2 fun isOdd x = x%2 != 0 - fun sprMain if ( programArgs.size() < 2 ) return diff --git a/tests/PerfTests/FibRanges/fib_op_base.spr b/tests/PerfTests/FibRanges/fib_op_base.spr index 5fe47be9..0e95ae80 100644 --- a/tests/PerfTests/FibRanges/fib_op_base.spr +++ b/tests/PerfTests/FibRanges/fib_op_base.spr @@ -2,10 +2,10 @@ import std.algorithms -fun fib(n: UInt): UInt +fun fib(n: UInt): UInt var a: UInt = 0 var b: UInt = 1 - for i = 0..n + for i = 0..n var aOld = a a = b b += aOld diff --git a/tests/PerfTests/GoogleBench/LoopTesterApp.spr b/tests/PerfTests/GoogleBench/LoopTesterApp.spr index f1122e46..e3e601a4 100644 --- a/tests/PerfTests/GoogleBench/LoopTesterApp.spr +++ b/tests/PerfTests/GoogleBench/LoopTesterApp.spr @@ -60,7 +60,6 @@ fun getNumNodes(this: @MaoCFG) = _basicBlockMap.size fun basicBlocksRange(this: @MaoCFG) = _basicBlockMap.values() - // // SimpleLoop // @@ -98,7 +97,6 @@ fun hash(this: @SimpleLoop) = counter fun >>(this: @SimpleLoop, os: @OutStream) os << "loop-" << counter << ", nest: " << nestingLevel << ", depth: " << depthLevel << endl - // // LoopStructureGraph // @@ -246,7 +244,6 @@ using BB_LAST = Byte(6) // Sentinel using kUnvisited = -1 // Marker for uninitialized nodes. using kMaxNonBackPreds = 32*1024 // Safeguard against pathologic algorithm behavior. - datatype HavlakLoopFinder _cfg: @MaoCFG _lsg: @LoopStructureGraph diff --git a/tests/PerfTests/Hash/TestHashPerf.spr b/tests/PerfTests/Hash/TestHashPerf.spr index b796fdfa..8455c906 100644 --- a/tests/PerfTests/Hash/TestHashPerf.spr +++ b/tests/PerfTests/Hash/TestHashPerf.spr @@ -153,6 +153,5 @@ fun sprMain testRemove(hashBag, n) ; - /*-<<>>*/ diff --git a/tests/PerfTests/LazyRanges/lazy_ranges_base.spr b/tests/PerfTests/LazyRanges/lazy_ranges_base.spr index 29e9023f..3b426e85 100644 --- a/tests/PerfTests/LazyRanges/lazy_ranges_base.spr +++ b/tests/PerfTests/LazyRanges/lazy_ranges_base.spr @@ -13,7 +13,6 @@ fun collatzLen(n: ULong): UInt ++len return len - fun sprMain if ( programArgs.size() < 2 ) return diff --git a/tests/StdLib/AlgorithmsTest1.spr b/tests/StdLib/AlgorithmsTest1.spr index db0cab4e..e90738ca 100644 --- a/tests/StdLib/AlgorithmsTest1.spr +++ b/tests/StdLib/AlgorithmsTest1.spr @@ -28,9 +28,8 @@ datatype MyObj fun <(this, other: @MyObj): Bool { return x < other.x; } datatype Greater - -fun ()(this: Greater, x: Int, y: Int): Bool { return x > y; } +fun ()(this: Greater, x: Int, y: Int): Bool { return x > y; } fun printRange(nr: ContiguousMemoryRange(Int)) while !nr.isEmpty() diff --git a/tests/StdLib/AlgorithmsTest2.spr b/tests/StdLib/AlgorithmsTest2.spr index 308b8c5a..6d9be5d1 100644 --- a/tests/StdLib/AlgorithmsTest2.spr +++ b/tests/StdLib/AlgorithmsTest2.spr @@ -41,15 +41,14 @@ datatype MyObj fun <(this, other: @MyObj): Bool { return x < other.x; } datatype Greater - + fun ()(this: Greater, x: Int, y: Int): Bool { return x > y; } datatype Even - + fun ()(this: Even, x: Int): Bool { return x % 2 == 0; } datatype Minus - fun ()(this: Minus, x: Int, y: Int) = x - y @@ -96,7 +95,6 @@ fun createRangeAscending(size: SizeType): ContiguousMemoryRange(Int) return ContiguousMemoryRange(Int)(ptr, ptrEnd) - fun test1() var nr = 0..10 diff --git a/tests/StdLib/AlgorithmsTest3.spr b/tests/StdLib/AlgorithmsTest3.spr index 831bccd8..39fab634 100644 --- a/tests/StdLib/AlgorithmsTest3.spr +++ b/tests/StdLib/AlgorithmsTest3.spr @@ -26,11 +26,11 @@ datatype MyObj fun <(this, other: @MyObj): Bool { return x < other.x; } datatype Greater - + fun ()(this: Greater, x: Int, y: Int): Bool { return x > y; } datatype Even - + fun ()(this: Even, x: Int): Bool { return x % 2 == 0; } fun printRange(nr: AnyType) @@ -112,7 +112,6 @@ fun test1() makeList(li) var lr = li.all() - printRange(copy(nr, lr)) printRange(lr) /*<< y; } datatype Even - + fun ()(this: Even, x: Int): Bool { return x % 2 == 0; } datatype Minus - fun ()(this: Minus, x: Int, y: Int) = x - y - fun printRange(nr: AnyType) while !nr.isEmpty() cout << nr.front() diff --git a/tests/StdLib/CheckTest.spr b/tests/StdLib/CheckTest.spr index 77e51ef4..9ba1dbad 100644 --- a/tests/StdLib/CheckTest.spr +++ b/tests/StdLib/CheckTest.spr @@ -10,7 +10,7 @@ fun check_associativity(x: Int) = x+2 == 2+x fun check_IntIdentity(x: Int) = (x+0) == x && (0+x) == x -fun classifier(x: Int): String +fun classifier(x: Int): String if ( x < 10 ) return "<10" if ( x < 20 ) return "<20" if ( x < 30 ) return "<30" @@ -18,7 +18,7 @@ fun classifier(x: Int): String fun isTrivial(x: Int) = x<5 -fun sprMain +fun sprMain if ( programArgs.size() < 2 ) return var n = programArgs(1) asInt @@ -26,7 +26,7 @@ fun sprMain if n == 1; testOk else if n == 2; testFailure -fun testOk +fun testOk forAll(Int) check (fun x = true) ~ "that we have something running" forAll(Int) check \check_associativity ~ "Int associativity" @@ -50,8 +50,7 @@ fun testOk //<<>(this: MyObj, os: @OutStream) { os << x; } datatype Greater - + fun ()(this: Greater, x: MyObj, y: MyObj): Bool { return x.x > y.x; } datatype Even - + fun ()(this: Even, x: MyObj): Bool { return x.x % 2 == 0; } fun createRangeAscending(size: SizeType): ContiguousMemoryRange(MyObj) @@ -296,7 +296,6 @@ false 0 0 0 0 0 0 >>>*/ - fun test10() var li: List(MyObj) = createRangeAscending(4) @@ -377,7 +376,6 @@ false 42 0 11 1 2 22 3 43 >>>*/ - fun test13() var li: List(MyObj) = createRangeAscending(4) var r = li.all() @@ -542,7 +540,6 @@ false 0 1 2 3 4 5 >>>*/ - fun test15() var li: List(MyObj) @@ -834,7 +831,6 @@ false 100 10 10 7 7 7 5 5 4 1 0 >>>*/ - fun test20() { // var li1: List(MyObj); diff --git a/tests/StdLib/PtrTest.spr b/tests/StdLib/PtrTest.spr index 12327897..b2c9ce50 100644 --- a/tests/StdLib/PtrTest.spr +++ b/tests/StdLib/PtrTest.spr @@ -169,7 +169,6 @@ fun test4() 43 destroyed >>>*/ - fun test5() var obj: @MyObj = newObj(42) var p = Ptr(MyObj)(obj) @@ -193,7 +192,6 @@ MyObj.print(some argument) 42 destroyed >>>*/ - fun test6() var obj: @MyObj = newObj(42) var p = Ptr(MyObj)(obj) diff --git a/tests/StdLib/RangesTest.spr b/tests/StdLib/RangesTest.spr index 391210b3..cc22487d 100644 --- a/tests/StdLib/RangesTest.spr +++ b/tests/StdLib/RangesTest.spr @@ -39,23 +39,23 @@ fun ==(this, other: @MyObj): Bool = x == other.x fun <(this, other: @MyObj): Bool = x < other.x datatype Greater - + fun ()(this: Greater, x: Int, y: Int): Bool { return x > y; } datatype Even - + fun ()(this: Even, x: Int): Bool { return x % 2 == 0; } datatype Minus - + fun ()(this: Minus, x: Int, y: Int) = x - y datatype Square - + fun ()(this: Square, x: AnyType) = x * x datatype Multiply - + fun ()(this: Multiply, x: AnyType, y: AnyType) = x * y datatype Fact @@ -110,7 +110,6 @@ fun createRangeAscending(size: SizeType): ContiguousMemoryRange(Int) return ContiguousMemoryRange(Int)(ptr, ptrEnd) - fun test1() var l = makeList() var lr = l.all() diff --git a/tests/StdLib/TupleTest.spr b/tests/StdLib/TupleTest.spr index cb4669c4..bedf9486 100644 --- a/tests/StdLib/TupleTest.spr +++ b/tests/StdLib/TupleTest.spr @@ -9,22 +9,22 @@ import check [initCtor] datatype MyObj2 x, y: Int -fun >>(o: MyObj1, os: @OutStream) +fun >>(o: MyObj1, os: @OutStream) os << o.x -fun >>(o: MyObj2, os: @OutStream) +fun >>(o: MyObj2, os: @OutStream) os << o.x << '#' << o.y using T2 = Tuple(MyObj1, MyObj2) using T4 = Tuple(MyObj1, MyObj2, Int rt, Bool rt) -fun arbitrary(t: Type): T2 Gen if t == T2 +fun arbitrary(t: Type): T2 Gen if t == T2 return mkGen(T2, \generateT2) -fun arbitrary(t: Type): T4 Gen if t == T4 +fun arbitrary(t: Type): T4 Gen if t == T4 return mkGen(T4, \generateT4) //! Generate an arbitrary tuple 2 -fun generateT2(sizeHint: UInt): T2 +fun generateT2(sizeHint: UInt): T2 var res: T2 var h: Int = sizeHint + 5 res.v1.x = randBetween(-h, h+1) @@ -32,7 +32,7 @@ fun generateT2(sizeHint: UInt): T2 res.v2.y = randBetween(-h, h+1) return res //! Generate an arbitrary tuple 4 -fun generateT4(sizeHint: UInt): T4 +fun generateT4(sizeHint: UInt): T4 var res: T4 var h: Int = sizeHint + 5 res.v1.x = randBetween(-h, h+1) @@ -45,7 +45,7 @@ fun generateT4(sizeHint: UInt): T4 fun isDefault2(t: T2) = t.v1.x == 0 && t.v2.x == 0 && t.v2.y == 0 fun isDefault4(t: T4) = t.v1.x == 0 && t.v2.x == 0 && t.v2.y == 0 && t.v3 == 0 && t.v4 == false -fun sprMain +fun sprMain var t2_1 = MyObj1(3) ~ MyObj2(4,5) var t4_1 = MyObj1(3) ~ MyObj2(4,5) ~ 6 ~ true var t2_2 = t2_1 diff --git a/tests/StdLib/VectorTest.spr b/tests/StdLib/VectorTest.spr index 2876cf73..a2634242 100644 --- a/tests/StdLib/VectorTest.spr +++ b/tests/StdLib/VectorTest.spr @@ -7,7 +7,6 @@ import std.algorithms(equal) import std.tuple import check - fun sprMain forAll(repeat(Vec(), 3)) check (fun x = x.isEmpty && x.size == 0) ~ "that a vector can be empty" forAll(Vec arbitrary) check (fun x = x.isEmpty || x.size > 0) ~ "that size is syncrhonized with isEmpty" @@ -17,7 +16,7 @@ fun sprMain if ( v.isEmpty != r.isEmpty ) return false if ( v.size != (r rangeSize) ) return false var sz = v.size - for i = 0..sz + for i = 0..sz if ( v(i) != r.front ) return false r.popFront return true @@ -27,7 +26,7 @@ fun sprMain var vec2: Vec = vec if ( vec2.isEmpty != vec.isEmpty ) return false if ( vec2.size != vec.size ) return false - for i = 0..vec.size + for i = 0..vec.size if ( vec2(i) != vec(i) ) return false return true }) ~ "vector's copy constructor" @@ -52,7 +51,7 @@ fun sprMain forAll(SizeType) check (fun sz: Bool { var vec: Vec = sz if ( vec.size != sz ) return false - for i = 0..sz + for i = 0..sz if ( vec(i) != Vec.ValueType() ) return false return true }) ~ "vector's sized constructor" @@ -68,7 +67,7 @@ fun sprMain }) ~ "that we have zero capacity of empty vectors" forAll(Vec arbitrary) check(fun vec: Bool { - for i = 0..vec.size + for i = 0..vec.size if ( vec(i) != vec.at(i) ) return false return true }) ~ "that at function yields the same as call operator" @@ -86,7 +85,7 @@ fun sprMain forAll(Vec arbitrary) check(fun vec: Bool { var r = vec.all if ( vec.size != (r rangeSize) ) return false - for i = 0..vec.size + for i = 0..vec.size if ( vec(i) != r.front ) return false r.popFront return r.isEmpty @@ -251,18 +250,17 @@ fun sprMain //<<< Vector checks - using Vec = Vector(Int) using TestRange = ContiguousMemoryRange(Int) -fun arbitrary(t: Type): Vec Gen if t == Vec +fun arbitrary(t: Type): Vec Gen if t == Vec return mkGen(Vec, \generateVec) -fun arbitrary(t: Type): TestRange Gen if t == TestRange +fun arbitrary(t: Type): TestRange Gen if t == TestRange return mkGen(t, \generateTestRange) //! Generate an arbitrary vector -fun generateVec(sizeHint: UInt): Vec +fun generateVec(sizeHint: UInt): Vec var res: Vec var h: Int = sizeHint + 5 var size = randBetween(0, h) @@ -272,7 +270,7 @@ fun generateVec(sizeHint: UInt): Vec return res //! Generate an arbitrary test range -fun generateTestRange(sizeHint: UInt): TestRange +fun generateTestRange(sizeHint: UInt): TestRange var h: Int = sizeHint + 3 var size = randBetween(0, h+1) @@ -287,7 +285,6 @@ fun generateTestRange(sizeHint: UInt): TestRange val = randBetween(-h, h+1) return ContiguousMemoryRange(Int)(ptr, ptrEnd) - datatype SubrangeTestData vec: Vec start, count: SizeType @@ -295,7 +292,7 @@ datatype SubrangeTestData fun >>(this: @SubrangeTestData, os: @OutStream) os << vec << ", start=" << start << ", count=" << count -fun arbitrary(t: Type): SubrangeTestData Gen if t == SubrangeTestData +fun arbitrary(t: Type): SubrangeTestData Gen if t == SubrangeTestData return mkGen(SubrangeTestData, (fun (sizeHint: UInt): SubrangeTestData { var res: SubrangeTestData res.vec = generateVec(sizeHint) @@ -313,7 +310,7 @@ datatype InsertValueTestData fun >>(this: @InsertValueTestData, os: @OutStream) os << vec << ", idx=" << idx << ", value=" << value -fun arbitrary(t: Type): InsertValueTestData Gen if t == InsertValueTestData +fun arbitrary(t: Type): InsertValueTestData Gen if t == InsertValueTestData return mkGen(InsertValueTestData, (fun (sizeHint: UInt): InsertValueTestData { var res: InsertValueTestData res.vec = generateVec(sizeHint) @@ -330,7 +327,7 @@ datatype InsertRangeTestData fun >>(this: @InsertRangeTestData, os: @OutStream) os << vec << ", idx=" << idx << ", values=" << values -fun arbitrary(t: Type): InsertRangeTestData Gen if t == InsertRangeTestData +fun arbitrary(t: Type): InsertRangeTestData Gen if t == InsertRangeTestData return mkGen(InsertRangeTestData, (fun (sizeHint: UInt): InsertRangeTestData { var res: InsertRangeTestData res.vec = generateVec(sizeHint) @@ -348,7 +345,6 @@ datatype Data fun >>(this: @Data, os: @OutStream) os << 'Data(' << x << ')\n' - fun ctor(this: @Data, other: Data) copyCtorCnt++ @@ -360,4 +356,3 @@ fun arbitrary(t: Type): DataVec Gen if t == DataVec fun generateDataVec(sizeHint: UInt): DataVec return DataVec(generateVec(sizeHint).all map (fun x = Data(x))) - diff --git a/tools/formatDetails/astNodes.spr b/tools/formatDetails/astNodes.spr index 6881f322..f925dd3c 100644 --- a/tools/formatDetails/astNodes.spr +++ b/tools/formatDetails/astNodes.spr @@ -9,7 +9,6 @@ import parserIf, parser, parserDefs, node import std.ranges, std.vector, std.newDelete - //! An AST node; we use this to represent the basic properties of our AST datatype AstNodeImpl kind: NodeKind @@ -72,7 +71,6 @@ fun createNode(l: Location, kind: NodeKind, name: StringRef): Node = new(AstNode var _nullAstNodeImpl: AstNodeImpl - //! Simple AST builder; creates AST based on AstNodeImpl objects datatype SimpleAstBuilder diff --git a/tools/formatDetails/consoleErrorReporter.spr b/tools/formatDetails/consoleErrorReporter.spr index 5de2018a..3df3b9aa 100644 --- a/tools/formatDetails/consoleErrorReporter.spr +++ b/tools/formatDetails/consoleErrorReporter.spr @@ -6,7 +6,6 @@ import ext import os - //! An error reporter that prints errors to the console datatype ConsoleErrorReporter diff --git a/tools/formatDetails/nodeKinds.spr b/tools/formatDetails/nodeKinds.spr index 5880bcfe..f5397191 100644 --- a/tools/formatDetails/nodeKinds.spr +++ b/tools/formatDetails/nodeKinds.spr @@ -51,7 +51,6 @@ using nkReturnStmt = NodeKind(38) // Not actually a node kind; just to represent a null node using nkNULL = NodeKind(255) - fun _asString(nk: NodeKind): StringRef if nk == nkNodeList return 'NodeList' else if nk == nkModifiers return 'Modifiers' diff --git a/tools/formatDetails/sourceData.spr b/tools/formatDetails/sourceData.spr index ea05426e..e7a34458 100644 --- a/tools/formatDetails/sourceData.spr +++ b/tools/formatDetails/sourceData.spr @@ -23,7 +23,6 @@ datatype SourceData //! We need to keep this alive, so that all the StringRef point to a valid object _src: TokenDataSource SharedPtr - //! Load the source data from the given filename. //! Ensures that all the tokens are link to their appropriate AST nodes fun load(res: @SourceData, filename: StringRef) diff --git a/tools/formatDetails/tokenDataSource.spr b/tools/formatDetails/tokenDataSource.spr index d64aa3a4..2b02f750 100644 --- a/tools/formatDetails/tokenDataSource.spr +++ b/tools/formatDetails/tokenDataSource.spr @@ -53,7 +53,6 @@ fun isEmpty(this: @TokenDataSourceRange) = _data._atEnd fun front(this: @TokenDataSourceRange) = _data._curToken fun popFront(this: @TokenDataSourceRange) = _data._popFront - fun readAst(filename: StringRef): Node var loc = mkLocation() var astBuilder: SimpleAstBuilder diff --git a/tools/formatTool.spr b/tools/formatTool.spr index 9aaf269b..d356fd59 100644 --- a/tools/formatTool.spr +++ b/tools/formatTool.spr @@ -1,7 +1,7 @@ //!! -I../src/SparrowFrontend/Grammar import formatDetails.sourceData import transforms.emptyTransform, transforms.defaultFormat, transforms.refToMut -import transforms.useLayout, transforms.removeEolSemicolons +import transforms.useLayout, transforms.removeEolSemicolons, transforms.removeExtraSpaces import checks.returnStmt, checks.moduleName import os @@ -26,10 +26,12 @@ fun sprMain if arg == '-format' transforms += \useLayoutFormatter transforms += \removeEolSemicolons + transforms += \removeExtraSpaces else if arg == '-f=layout' transforms += \useLayoutFormatter transforms += \removeEolSemicolons else if arg == '-f=empty' ; transforms += \emptyTransform + else if arg == '-f=spaces' ; transforms += \removeExtraSpaces else if arg == '-f=ref-to-mut' ; transforms += \refToMut else if arg == '-i' ; inPlace = true else if arg == '-check' diff --git a/tools/transforms/removeExtraSpaces.spr b/tools/transforms/removeExtraSpaces.spr new file mode 100644 index 00000000..bace3d94 --- /dev/null +++ b/tools/transforms/removeExtraSpaces.spr @@ -0,0 +1,35 @@ +module formatTool.transforms.removeExtraSpaces + +import utils +import formatDetails.sourceData + +fun removeExtraSpaces(src: @SourceData) + _removeEndSpaces(src) + _removeMultipleEmptyLines(src) + +//! Remove spaces at the end of the line +fun _removeEndSpaces(src: @SourceData) + for i = 0..Int(src.tokens.size) + var tok: @TokenData = src.tokens(i) + var remaining = src.tokens.subrange(i+1) + if tok.canFormat && tok.type == tkWHITESPACE && tok.content.size > 0 \ + && nextIsNewline(remaining, false) + tok.content = '' + +//! Remove multiple consecutive empty lines +fun _removeMultipleEmptyLines(src: @SourceData) + var lastLineWithVisible = 0 + var numNewlines = 0 + for i = 0..Int(src.tokens.size) + var tok: @TokenData = src.tokens(i) + var remaining = src.tokens.subrange(i+1) + + if tok.type != tkWHITESPACE && tok.type != tkEOL + lastLineWithVisible = tok.loc.start.line + numNewlines = 0 + if tok.type == tkEOL + if lastLineWithVisible != tok.loc.start.line + numNewlines++ + + if numNewlines >= 3 && tok.canFormat + clearToken(tok) diff --git a/tools/transforms/utils.spr b/tools/transforms/utils.spr index 853074a1..9095246a 100644 --- a/tools/transforms/utils.spr +++ b/tools/transforms/utils.spr @@ -41,12 +41,14 @@ fun clearTokenLine(idx: Int, tokens: @TokenVector) clearToken(tokens(i)) //! Checks if the next character is a newline (ignoring whitespaces and comments) -fun nextIsNewline(remaining: TokensRange): Bool +fun nextIsNewline(remaining: TokensRange, ignoreComment: Bool = true): Bool for tok: @TokenData = remaining var tk = tok.type if tk == tkEOL || tk == tkEND return true - if tk == tkWHITESPACE || tk == tkCOMMENT + if tk == tkWHITESPACE + continue + else if ignoreComment && tk == tkCOMMENT continue else return false