Ejemplo n.º 1
0
        protected Definition(Position position, string name, IEnumerable<IBoundDecl> typeArgs)
        {
            Position = position;
            mName = name;

            if (typeArgs == null)
            {
                TypeArguments = new IBoundDecl[0];
            }
            else
            {
                TypeArguments = typeArgs.ToArray();
            }
        }
Ejemplo n.º 2
0
        public Function(Position position, string name, FuncType type, IEnumerable<string> paramNames, IUnboundExpr body,
            IEnumerable<IBoundDecl> typeArgs, bool hasInferrableTypeArguments)
            : base(position, name, typeArgs)
        {
            if (position == null) throw new ArgumentNullException("position");
            if (type == null) throw new ArgumentNullException("type");

            if (paramNames != null)
            {
                ParamNames.AddRange(paramNames);
            }

            Body = new Expr(body);

            Type = type;
            HasInferrableTypeArguments = hasInferrableTypeArguments;
        }
Ejemplo n.º 3
0
 protected Definition(Position position, string name)
     : this(position, name, new IBoundDecl[0])
 {
 }
Ejemplo n.º 4
0
 public void SetPosition(Position position)
 {
     mPosition = position;
 }
Ejemplo n.º 5
0
 public CodeBuilder(NameGenerator generator, Position position)
 {
     mGenerator = generator;
     mPosition = position;
 }
Ejemplo n.º 6
0
 public CompileException(Position position, string message)
     : base(message)
 {
     Position = position;
 }
Ejemplo n.º 7
0
        // <-- GenericDecl FnArgsDecl Block
        private void FunctionDefinition(Namespace namespaceObj, string name, Position position)
        {
            var typeParams = TypeParams();

            var paramNames = new List<string>();
            var funcType = FnArgsDecl(paramNames);
            var body = Block();

            var function = new Function(position, name, funcType, paramNames, body);

            if (typeParams.Count == 0)
            {
                namespaceObj.Functions.Add(function);
            }
            else
            {
                namespaceObj.GenericFunctions.Add(new GenericFunction(function, typeParams));
            }
        }
Ejemplo n.º 8
0
 public Token(Position position, TokenType type)
     : this(position)
 {
     Type = type;
 }
Ejemplo n.º 9
0
 public Token(Position position, string value)
     : this(position, TokenType.String)
 {
     StringValue = value;
 }
Ejemplo n.º 10
0
 public Function(Position position, string name, FuncType type, IEnumerable<string> paramNames, IUnboundExpr body)
     : this(position, name, type, paramNames, body, null, false)
 {
 }
Ejemplo n.º 11
0
 public Token(Position position, int value)
     : this(position, TokenType.Int)
 {
     IntValue = value;
 }
Ejemplo n.º 12
0
 public Token(Position position, bool value)
     : this(position, TokenType.Bool)
 {
     BoolValue = value;
 }
Ejemplo n.º 13
0
 public Token(Position position, TokenType type, string text)
     : this(position)
 {
     Type = type;
     StringValue = text;
 }
Ejemplo n.º 14
0
        public INamedType Find(NameSearchSpace searchSpace, Position position,
            string name, IEnumerable<IBoundDecl> typeArgs)
        {
            // look through the namespaces
            foreach (var potentialName in searchSpace.SearchFor(name))
            {
                // look for a concrete type
                var type = Find(potentialName, typeArgs);
                if (type != null) return type;

                // look for a generic
                foreach (var structure in mGenericStructs)
                {
                    // names must match
                    if (structure.Name != potentialName) continue;

                    // number of type args must match
                    if (typeArgs.Count() != structure.TypeParameters.Count) continue;

                    return structure.Instantiate(mCompiler, typeArgs);
                }

                //### bob: gross copy/paste of above
                // look for a generic
                foreach (var union in mGenericUnions)
                {
                    // names must match
                    if (union.Name != potentialName) continue;

                    // number of type args must match
                    if (typeArgs.Count() != union.TypeParameters.Count) continue;

                    return union.Instantiate(mCompiler, typeArgs);
                }
            }

            // not found
            throw new CompileException(position, "Could not find a type named " + name + ".");
        }
Ejemplo n.º 15
0
 public CompileError(CompileStage stage, Position position, string message)
 {
     Stage = stage;
     Position = position;
     Message = message;
 }
Ejemplo n.º 16
0
 public ParseException(Position position, string message)
     : base(String.Format("Parse error at (line {0} column {1}-{2}): {3}", position.Line, position.Column, position.Column + position.Length, message))
 {
 }
Ejemplo n.º 17
0
 private Token(Position position)
 {
     Position = position;
 }