public Block(Cursor cursor, Statement[] statements) : base(NodeKind.Block, cursor) { _statements = statements; foreach (Statement statement in _statements) statement.Above = this; }
public TextLiteral(Cursor cursor, Type type, string value) : base(NodeKind.TextLiteral, cursor) { _type = type; _type.Above = this; _value = value; }
public CardinalLiteral(Cursor cursor, Type type, uint value) : base(NodeKind.CardinalLiteral, cursor) { _type = type; _type.Above = this; _value = value; }
public Parameter(Cursor cursor, SymbolDefinition name, DirectionKind direction, Type type) : base(NodeKind.Parameter, cursor, name) { _direction = direction; _type = type; _type.Above = this; }
public CallExpression(Cursor cursor, Expression callee, Expression[] arguments) : base(NodeKind.CallExpression, cursor) { _callee = callee; _callee.Above = this; _arguments = arguments; foreach (Expression argument in _arguments) argument.Above = this; }
public Profile(Cursor cursor, Type type, Parameter[] parameters) : base(NodeKind.Profile, cursor) { _type = type; _type.Above = this; _parameters = parameters; foreach (Parameter parameter in _parameters) parameter.Above = this; }
public Node(NodeKind kind, Cursor cursor) { /** \note The node ids are 1-based to make it easier to detect errors. */ _id = _nodes.Count + 1; _nodes[_id] = this; _kind = kind; // Make a deep copy of the position so as to protect it from unwanted side-effects. _cursor = new Cursor(cursor); }
public Routine( NodeKind kind, Cursor cursor, SymbolDefinition name, Profile profile, Block block ) : base(kind, cursor, name) { _profile = profile; _profile.Above = this; _block = block; _block.Above = this; }
/** Creates a default getter for use in a field or a guard. */ private GetStatement CreateDefaultGetter(Cursor cursor, string value) { // Create profile of the default getter. Profile profile = new Profile( position, new NamedType(position, new SymbolReference(position, PathKind.Instance, value)), new Parameter[0] ); // Create sole embedded statement; a return statement that returns the value of the data member. Statement statement = new ReturnExpressionStatement( position, new NamedExpression(position, new SymbolReference(position, PathKind.Instance, value)) ); Statement[] statements = new Statement[1]{ statement }; Block block = new Block(position, statements); return new GetStatement( position, new SymbolDefinition(position, "get", SymbolKind.Getter), profile, block ); }
public Token(Cursor cursor) { _cursor = new Cursor(cursor); }
public Token() { _cursor = new Cursor(); }
public PrefixReference(Cursor cursor, Expression prefix, string symbol) : base(NodeKind.PrefixReference, cursor, symbol) { _prefix = prefix; _prefix.Above = this; }
public GlobalReference(Cursor cursor, string symbol) : base(NodeKind.GlobalReference, cursor, symbol) { }
public SymbolErrorExists(Cursor cursor, string name) : base(cursor, name) { }
public SymbolErrorUnknown(Cursor cursor, string name) : base(cursor, name) { }
public BlockStatement(Cursor cursor, Block block) : base(NodeKind.BlockStatement, cursor) { _block = block; _block.Above = this; }
/** Constructor for the \c Error class. */ public Error(ErrorKind level, Cursor cursor, int code, string text) : base(cursor, text) { _level = level; _code = code; }
public ReturnExpressionStatement(Cursor cursor, Expression expression) : base(NodeKind.ReturnExpressionStatement, cursor) { _expression = expression; _expression.Above = this; }
public TextType(Cursor cursor) : base(NodeKind.TextType, cursor) { }
public Module(Cursor cursor, Block block) : base(NodeKind.Module, cursor) { _block = block; _block.Above = this; }
public EntryStatement(Cursor cursor, SymbolDefinition name, Profile profile, Block block) : base(NodeKind.EntryStatement, cursor, name, profile, block) { }
/** Looks up an absolute encoded (mangled) symbol. */ public Symbol LookupEncoded(Cursor cursor, string name) { if (name.Substring(0, 4) != "$b0$") throw new Toolbox.Error(Toolbox.ErrorKind.Fatal, cursor, 0, "Invalid symbol: " + name); Folder<Symbol> folder = _volume; int first = 4; int other = first; do { string symbol; other = name.IndexOf('!', first); if (other == -1) symbol = "$b0$" + name.Substring(first); else symbol = name.Substring(first, other - first); first = other + 1; folder = (Folder<Symbol>) folder.Resolve(symbol); if (folder == null) throw new Toolbox.Error(Toolbox.ErrorKind.Fatal, cursor, 0, "Unknown symbol: " + name); } while (other != -1); return folder.Data; }
public ReturnNothingStatement(Cursor cursor) : base(NodeKind.ReturnNothingStatement, cursor) { }
public InternalError(Cursor cursor, string message) : base(message) { _cursor = new Cursor(cursor); // Make deep copy to avoid problems with cursors that change afterwards. }
public CallStatement(Cursor cursor, Expression expression) : base(NodeKind.CallStatement, cursor) { _expression = expression; _expression.Above = this; }
public Definition(NodeKind kind, Cursor cursor, SymbolDefinition name) : base(kind, cursor) { _name = name; _name.Above = this; }
public MemberReference(Cursor cursor, string symbol) : base(NodeKind.MemberReference, cursor, symbol) { }
public void Report(ErrorKind level, Cursor cursor, string text) { Report(level, cursor, 0, text); }
public ScopeStatement(Cursor cursor, SymbolDefinition name, Block block) : base(NodeKind.ScopeStatement, cursor, name) { _block = block; _block.Above = this; }
public void Report(ErrorKind level, Cursor cursor, int code, string text) { Error error = new Error(level, cursor, code, text); _lock.Acquire(); _errors.Add(error); _lock.Release(); // update Failed property that indicates whether one or more errors have occured switch (level) { case ErrorKind.Debug : break; case ErrorKind.Error : _failed = true; break; case ErrorKind.Fatal : _failed = true; break; case ErrorKind.Internal : _failed = true; break; case ErrorKind.Notice : break; case ErrorKind.Unhandled: _failed = true; break; case ErrorKind.Warning : break; default: throw new InternalError("Unknown ErrorKind value encountered: " + level.ToString()); } // don't report the event if the trace level does not allow it if (level > _level) return; System.Text.StringBuilder result = new System.Text.StringBuilder(); if (cursor != null) result.Append(cursor.ToString()); if (result.Length > 0) result.Append(' '); string name = null; switch (level) { case ErrorKind.Debug : name = "DEBUG"; break; case ErrorKind.Error : name = "Error"; break; case ErrorKind.Fatal : name = "Fatal error"; break; case ErrorKind.Internal : name = "Internal error"; break; case ErrorKind.Notice : name = null; break; case ErrorKind.Unhandled: name = "Unhandled error"; break; case ErrorKind.Warning : name = "Warning"; break; default: throw new InternalError("Unknown ErrorKind value encountered: " + level.ToString()); } if (name != null) result.Append(name); if (code != 0) result.Append(" " + code.ToString()); if (name != null) result.Append(": "); result.Append(text); _writer.WriteLine(result.ToString()); }