Skip to content

Instantly share code, notes, and snippets.

View leppie's full-sized avatar
🤡

Llewellyn Pritchard leppie

🤡
  • Cape Town, South Africa
View GitHub Profile
@leppie
leppie / pdb2xml.cmd
Last active February 5, 2016 19:12
Roslyn Build dir dropper: pdb2xml.cmd
@echo using System.IO;class pdb2xml{static void Main(string[]a){using(Stream f=File.OpenRead(a[0]),p=File.OpenRead(a[1]))^
System.Console.WriteLine(Roslyn.Test.PdbUtilities.PdbToXmlConverter.ToXml(p,f));}}>pdb2xml.cs
@csc /nologo /r:System.IO.dll,System.Runtime.dll,Roslyn.Test.PdbUtilities.dll pdb2xml.cs&&del pdb2xml.cs&&pdb2xml %*
@leppie
leppie / foo.cmd
Last active February 10, 2016 18:04
Command line parsing in a batch file (or scripting for the mildly insane)
@echo off
setlocal EnableDelayedExpansion
:: user settings
set VERBOSE=0
set ERRORS=0
:: arg parsing settings
set ARGS=verbose debug-mode
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
public class App
{
@leppie
leppie / foo.cs
Created December 18, 2015 13:32
Does this compile pre-Roslyn?
using System;
enum Foo { Bar, Baz }
public class P
{
static void Foo(Foo foo = Foo.Baz) {}
static void Main()
{
// why masking is a good habit
// the following fails are runtime
static byte[] ToByteArray(int i)
{
checked
{
var b = new byte[4];
b[0] = (byte)(i);
b[1] = (byte)((i >> 8));
b[2] = (byte)((i >> 16));
@leppie
leppie / test-cs.cmd
Last active July 3, 2021 11:57
Helper script for testing Roslyn C# compiler bits
@echo off
@setlocal
rem arg can be blank to test all or one of Emit, Symbol, Semantic, Syntax (or WinRT, CommandLine, these untested)
set Area=%1
if "%Area%" == "" set Area=*
msbuild /v:m /m BuildAndTest.proj /p:IncludePattern=Roslyn.Compilers.CSharp.%Area%.UnitTests.dll
@leppie
leppie / test.sls
Created November 20, 2015 10:24
Tail call test
c:\Users\lpritcha\Downloads\IronScheme-115404\IronScheme>IronScheme.Console32-v2.exe
IronScheme TFS:115404 ironscheme.codeplex.com © 2007,2008,2009,2010,2011,2012,2013,2014,2015 Llewellyn Pritchard (.NET 2.0 32-bit)
> (import (tc))(test)
Unhandled exception during evaluation:
&assertion
&message: "moo"
&irritants: ()
&stacktrace
[1] "ironscheme.exceptions::raise(obj)"
[2] "tc.test##even?$3(n)"
@leppie
leppie / report.tab
Created November 10, 2015 11:30
Profiling session for (ironscheme-test). Load in excel.
This file has been truncated, but you can view the full file.
Name Count Inc Time Ex Time Avg Inc Time Avg Ex Time
IronScheme.Runtime.Program::Main(String[]):int32 1 0.00 0.00 0.0000 0.0000
IronScheme.Runtime.Program::Args(String[]+String+<UNKNOWN>):String[] 2 0.04 0.04 0.0223 0.0216
IronScheme.Runtime.Program::EnableMulticoreJIT():void 1 0.14 0.05 0.1401 0.0531
System.Object::.ctor():void 19759984 835.79 835.79 0.0000 0.0000
System.Object::Equals(Object):bool 296873 13.01 13.01 0.0000 0.0000
System.Object::Equals(Object+Object):bool 872273 341.05 286.73 0.0004 0.0003
System.Object::ReferenceEquals(Object+Object):bool 2113662 113.03 113.03 0.0001 0.0001
System.Object::GetHashCode():int32 856605 69.71 69.71 0.0001 0.0001
System.Object::Finalize():void 97 0.01 0.01 0.0001 0.0001
@leppie
leppie / foo.ss
Created November 3, 2015 17:06
Columnwise summing in Scheme
(define d
'((1 2 3 4)
(4 5 6 7)
(7 8 9 10)
(8 9 10 11)
(1 2 3 4)))
(apply map + d)
@leppie
leppie / foo.cs
Created October 27, 2015 15:43
New way of loading array data for bignums
private void EmitMetadataArray(uint[] p)
{
var size = p.Length * 4;
byte[] data = new byte[size];
Buffer.BlockCopy(p, 0, data, 0, size);
var fb = this._typeGen.TypeBuilder.DefineInitializedData(Guid.NewGuid().ToString(), data, FieldAttributes.Static);
EmitInt(p.Length);
Emit(OpCodes.Newarr, typeof(uint));
Emit(OpCodes.Dup);
Emit(OpCodes.Ldtoken, fb);