protected Definition(Position position, string name, IEnumerable<IBoundDecl> typeArgs) { Position = position; mName = name; if (typeArgs == null) { TypeArguments = new IBoundDecl[0]; } else { TypeArguments = typeArgs.ToArray(); } }
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; }
protected Definition(Position position, string name) : this(position, name, new IBoundDecl[0]) { }
public void SetPosition(Position position) { mPosition = position; }
public CodeBuilder(NameGenerator generator, Position position) { mGenerator = generator; mPosition = position; }
public CompileException(Position position, string message) : base(message) { Position = position; }
// <-- 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)); } }
public Token(Position position, TokenType type) : this(position) { Type = type; }
public Token(Position position, string value) : this(position, TokenType.String) { StringValue = value; }
public Function(Position position, string name, FuncType type, IEnumerable<string> paramNames, IUnboundExpr body) : this(position, name, type, paramNames, body, null, false) { }
public Token(Position position, int value) : this(position, TokenType.Int) { IntValue = value; }
public Token(Position position, bool value) : this(position, TokenType.Bool) { BoolValue = value; }
public Token(Position position, TokenType type, string text) : this(position) { Type = type; StringValue = text; }
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 + "."); }
public CompileError(CompileStage stage, Position position, string message) { Stage = stage; Position = position; Message = message; }
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)) { }
private Token(Position position) { Position = position; }