Skip to content

Instantly share code, notes, and snippets.

ant libs.llvm
Buildfile: /home/soc/Entwicklung/scala/build.xml
libs.start:
libs.pre-llvm:
init.starr:
init:
../../../src/llvm/ffi/scala/ffi/alloc.scala:16: error: type mismatch;
found : scala.ffi.CInt
(which expands to) Int
required: scala.ffi.CSizeT
(which expands to) Long
val ptr: Ptr[A] = mallocBytes(n)
^
cp -R scala-llvm-bck scala-llvm-backend
LS='src/compiler/scala/tools/nsc/backend/llvm'
git filter-branch --subdirectory-filter $LS -- --all
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all
git tag -l | xargs git tag -d
git gc --prune=now
@soc
soc / UnitsEx.scala
Created February 5, 2012 15:33
Problem with implicits ...
object UnitsEx {
case class Quantity[M <: MInt, T: Numeric](value: T) {
private val num = implicitly[Numeric[T]]
def *[M2 <: MInt](m: Quantity[M2, T]) = Quantity[M, T](num.times(value, m.value))
}
implicit def measure[T: Numeric](v: T): Quantity[_0, T] = Quantity[_0, T](v)
implicit def numericToQuantity[T: Numeric](v: T): QuantityConstructor[T] = new QuantityConstructor[T](v)
class QuantityConstructor[T: Numeric](v: T) {
@soc
soc / UnitsEx2.scala
Created February 5, 2012 15:35
Problem with implicits ...
object UnitsEx2 {
case class Quantity[T: Numeric](value: T) {
private val num = implicitly[Numeric[T]]
def *(m: Quantity[T]) = Quantity[T](num.times(value, m.value))
}
implicit def measure[T: Numeric](v: T): Quantity[T] = Quantity[T](v)
implicit def numericToQuantity[T: Numeric](v: T): QuantityConstructor[T] = new QuantityConstructor[T](v)
class QuantityConstructor[T: Numeric](v: T) {
soc@laptop ~/Entwicklung/scala/docs/examples/llvm (git)-[llvm] % make run-sample
make -C ../../../src/llvm/rt llvmrt.a runscala
make[1]: Entering directory `/home/soc/Entwicklung/scala/src/llvm/rt'
make[1]: `llvmrt.a' is up to date.
g++ `icu-config --ldflags-searchpath --ldflags-icuio` `llvm-config --ldflags core jit bitreader native interpreter archive bitwriter` `apr-1-config --link-ld --libs` -o runscala runscala.o wrapper.o unwind.o `icu-config --ldflags-libsonly --ldflags-icuio` `llvm-config --libs core jit bitreader native interpreter archive bitwriter` -lm
runscala.o: In function `main':
/home/soc/Entwicklung/scala/src/llvm/rt/runscala.cpp:109: undefined reference to `llvm::MemoryBuffer::getFileOrSTDIN(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, long, stat*)'
runscala.o: In function `ForceCodegenLinking':
/usr/lib/llvm-2.8/include/llvm/CodeGen/LinkAllCodegenComponents.h:38: undefined reference to `llvm::createPBQPRegisterAllocator()'
/usr/lib/llvm-2.9/lib/libL
class Boopy {
private val s = new Schnuck
def observer : PartialFunction[ Any, Unit ] = s.observer
private class Schnuck extends javax.swing.AbstractListModel {
model =>
val observer : PartialFunction[ Any, Unit ] = {
case "Boopy" => fireIntervalAdded( model, 0, 1 )
}
def getSize = 0
abstract class NumericRange[T]
(val start: T, val end: T, val step: T, val isInclusive: Boolean)
(implicit num: Integral[T])
extends AbstractSeq[T] with IndexedSeq[T] with Serializable {
final override def sum[B >: T](implicit num: Numeric[B]): B = {
import num.Ops
if (isEmpty) this.num fromInt 0
else if (numRangeElements == 1) head
else ((this.num fromInt numRangeElements) * (head + last) / (this.num fromInt 2))
final class SBigInt private(final val signum: Int, final private[math] val arr: Array[Int]) {
...
/**
* Standard Serialization would work, but we have to make sure
* that we sanitize the array to verify our invariant of no leading
* “zeroes” in our magnitude.
*
* Otherwise all methods depending on it will be broken.
% make run-sample
make -C ../../../src/llvm/runtime llvmrt.a runscala
make[1]: Entering directory `/home/soc/Entwicklung/scala-llvm/src/llvm/runtime'
clang -std=c99 -fexceptions `icu-config --cppflags` -O4 -emit-llvm -c -o runtime.bc runtime.c
clang -std=c99 -fexceptions `icu-config --cppflags` -O4 -emit-llvm -c -o object.bc object.c
clang -std=c99 -fexceptions `icu-config --cppflags` -O4 -emit-llvm -c -o boxes.bc boxes.c
clang -std=c99 -fexceptions `icu-config --cppflags` -O4 -emit-llvm -c -o arrays.bc arrays.c
arrays.c:134:8: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if(i < 0 || i >= arr->length) {
~ ^ ~