Skip to content

Instantly share code, notes, and snippets.

View kg's full-sized avatar

Katelyn Gadd kg

View GitHub Profile
@kg
kg / FannkuchRedux.cs
Created April 13, 2011 10:19
FannkuchRedux.cs JSIL output
/* The Computer Language Benchmarks Game
http://shootout.alioth.debian.org/
contributed by Isaac Gouy, transliterated from Mike Pall's Lua program
*/
using System;
public static class Program {
public static int[] fannkuch (int n) {
@kg
kg / BinaryTrees.cs
Created April 17, 2011 01:04
BinaryTrees.cs JSIL output
/* The Computer Language Benchmarks Game
http://shootout.alioth.debian.org/
contributed by Marek Safar
*/
using System;
public static class Program {
const int minDepth = 4;
public class MaterialSet : Squared.Render.MaterialSetBase {
public Squared.Render.MaterialDictionary<BlendModes> Geometry, TexturedGeometry, ScreenSpaceGeometry;
public Squared.Render.MaterialDictionary<BlendModes> Bitmap, ScreenSpaceBitmap;
public DelegateMaterial Glimmer;
public DelegateMaterial Text;
public DelegateMaterial BlurredTile;
public DelegateMaterial Clear;
public DelegateMaterial FlipRB;
}
public interface IInteractable {
bool CanInteract (IHasBounds interactor);
void BeginInteract (IHasBounds interactor);
void EndInteract (IHasBounds interactor);
string GetInteractLegend ();
}
public interface IUpdateable {
bool AllowWake { get; }
bool AllowSleep { get; }
public abstract class TooltipContentBase {
public Font Font;
public Point Location;
public Size Size;
public abstract void Render (Graphics g);
public abstract Size Measure (Graphics g);
}
public class DeltaInfoTooltipContent : TooltipContentBase {
public abstract class JSNode {
public virtual IEnumerable<JSNode> Children {
get {
yield break;
}
}
public IEnumerable<JSNode> AllChildrenRecursive {
get {
foreach (var child in Children) {
// yhlqss0l, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Program = {};
Program.Main = function (args) {
a = JSIL.JaggedArray.New(System.String, 5, 10);
h = a.GetLength(0);
w = a.GetLength(1);
y = 0;
while ((y < h)) {
x = 0;
@kg
kg / Future.cs
Created May 4, 2011 05:52
Solving Problems With Asynchrony #3
public interface IFuture {
Exception Error {
get;
}
bool Completed {
get;
}
bool Failed {
get;
}
public void VisitNode (JSBinaryOperatorExpression boe) {
if (boe.Operator != JSOperator.Assignment) {
base.VisitNode(boe);
return;
}
if (IsStruct(boe.Left.GetExpectedType(TypeSystem)) || IsStruct(boe.Right.GetExpectedType(TypeSystem))) {
Debug.WriteLine(String.Format("struct assignment {0} = {1}", boe.Left, boe.Right));
if (boe.Right is JSLiteral) {
Debug.WriteLine(" copy not needed, literal");
@kg
kg / IndexBuiltinByName.cs
Created May 6, 2011 07:13
JSIL metaprogramming test case
using System;
using JSIL;
public static class Program {
public static void Main (string[] args) {
const string pri = "pri";
string nt = "nt";
var p = Builtins.Global[pri + nt];
if (p != null)