view misc/Location.d @ 24:2d28b21faad6 new_gen

New codegen! Rewritten codegen to use the llvm bindings Everything except struct are back to normal, and there a a few additions. 1. Correct code in more cases, return at the end of a while/if wont generate a "ret" followed by a "br". 2. Better scope, "int x = x" now illegal 3. Probably more
author Anders Halager <halager@gmail.com>
date Sat, 19 Apr 2008 18:29:42 +0200
parents 606a57c90a0b
children 41d23f2762c3
line wrap: on
line source

module misc.Location;

import misc.DataSource;

import Integer = tango.text.convert.Integer,
       tango.text.Util;

struct Location
{
    uint position;
    DataSource source;

    char[] toString ()
    {
        int lineNumber = split(source.get(0, position), "\n").length;
        return source.name ~ ":" ~ Integer.toString(lineNumber);
    }

    char[] get(uint length)
    {
        return source.get(position, length);
    }
}