internal OR(Node lhs, Node rhs, YYLTYPE location) : base(location) { Debug.Assert(lhs != null && rhs != null); this.lhs = lhs; this.rhs = rhs; }
protected Node _else; // optional internal COND(Node cond, Node body, Node _else, YYLTYPE location) : base(location) { Debug.Assert(cond != null); this.cond = cond; this.body = body; this._else = _else; }
internal ARRAY(Node args, YYLTYPE location) : base(location) { if (args is ARGS) this.args = (ARGS)args; else this.args = new ARGS(args, null, null, null, args.location, false); }
internal ARGS(Node parameters, Node hashlist, Node array, Node block, YYLTYPE location, bool parens): base(location) { this.parameters = parameters; this.hashlist = hashlist; this.array = array; this.block = block; this.parens = parens; }
internal FORMALS(Node normal, Node optional, Node rest, Node block, YYLTYPE location) : base(location) { this.normal = (StaticLocalVar)normal; this.optional = (ASSIGNMENT)optional; this.rest = (StaticLocalVar)rest; this.block = (StaticLocalVar)block; }
internal StringTerminator(int func, int term, int paren, int name, YYLTYPE location): base(location) { this.func = func; this.term = term; this.paren = paren; this.name = name; this.nest = 0; }
internal ARGS(YYLTYPE location, bool parens): base(location) { this.parameters = null; this.hashlist = null; this.array = null; this.block = null; this.parens = parens; }
internal override VAR create_local_here(string id, YYLTYPE location) { if (frame.dynamic_vars == null) frame.dynamic_vars = new Dictionary<string, object>(); if (!frame.dynamic_vars.ContainsKey(id)) frame.dynamic_vars.Add(id, null); return new DynamicLocalVar(id, this, location); }
internal TRY_BLOCK(Scope parent_scope, Node body, Node rescue, Node _else, Node ensure, YYLTYPE location) : base(location) { this.parent_scope = parent_scope; this.body = body; this.rescue = (RESCUE_CLAUSE)rescue; this._else = _else; this.ensure = ensure; }
internal CALL(Node args, YYLTYPE location) : base(location) { if (args == null) this.args = null; else if (args is ListGen) this.args = (ListGen)args; else this.args = new ARGS(args, null, null, null, location, false); }
internal CONCAT(Node A, Node B, YYLTYPE location) : base(location) { if (A == null || A is VALUE && ((string)((VALUE)A).value) == "") { this.head = B; return; } Node headA, headB; if (A is CONCAT) headA = ((CONCAT)A).head; else headA = A; if (B is CONCAT) headB = ((CONCAT)B).head; else headB = B; this.head = Parser.append(headA, headB); }
internal ControlFlowNode(Scope parent_scope, ARGS return_val, YYLTYPE location) : base(location) { this.parent_scope = parent_scope; // no return value if (return_val == null) return; if (return_val.block != null) throw new System.Exception("block argument should not be given"); // just a single value => return that value if (return_val.hashlist == null && return_val.array == null && return_val.parameters.nd_next == null) { this.return_val = return_val.parameters; return; } // just hash values => return a HASH if (return_val.parameters == null && return_val.array == null) { this.return_val = new HASH(return_val.hashlist, return_val.location); return; } // return *p => if p is an ARRAY then ... else ... if (return_val.parameters == null && return_val.hashlist == null) { this.array = return_val.array; this.return_val = new ProxyNode(ReturnArray, return_val.location); } else { this.args = return_val; this.return_val = new ProxyNode(ReturnRubyArray, return_val.location); } }
internal FORBODY(Scope current, YYLTYPE location): base(current, location) { }
internal BLOCKARGS(YYLTYPE location) : base(location) { }
internal Scope(Node body, YYLTYPE location) : base(location) { this.body = body; }
internal VAR get_outer_local(string id, BLOCK block, int depth, YYLTYPE location) { if (defined_statically(id)) return new StaticOuterVar(id, block, depth, location); else if (defined_dynamically(id)) return new DynamicOuterVar(id, block, depth, location); else return block_parent.get_outer_local(id, block, depth + 1, location); }
// END { body } internal END(Scope parent_scope, YYLTYPE location) : base(parent_scope, location) { }
internal override VAR create_local_here(string id, YYLTYPE location) { block_parent.create_local_here(id, location); return get_outer_local(id, this, 0, location); }
private Node body; // optional internal begin(Node body, YYLTYPE location) : base(location) { this.body = body; }
internal override void Init(YYLTYPE location, params object[] inputs) { this.location = location; this.formals = (FORMALS)inputs[0]; this.body = (Node)inputs[1]; }
internal override void Init(YYLTYPE location, params object[] input) { this.location = location; this.args = new MLHS(null, location); this.body = (Node)input[0]; }
internal virtual VAR add_local(string id, YYLTYPE location) { if (defined_statically(id)) return new StaticLocalVar(id, this, location); else if (defined_dynamically(id)) return new DynamicLocalVar(id, (BLOCK)this, location); else if (has_local(id)) return get_outer_local(id, (BLOCK)this, 0, location); else return create_local_here(id, location); }
internal virtual VAR add_locally(string id, YYLTYPE location) { if (defined_statically(id)) return new StaticLocalVar(this, id, location); else return create_local_here(id, location); }
YYLTYPE name_location; // used by codeDOM for replacing names internal DEFN(Scope parent, string method_id, YYLTYPE location, YYLTYPE name_location) : base(parent, location) { this.method_id = method_id; this.name_location = name_location; }
internal virtual VAR create_local_here(string id, YYLTYPE location) { locals_list.Add(id); return new StaticLocalVar(this, id, location); }
// def receiver.method_id(args) // body // end internal DEFS(Scope parent, string method_id, YYLTYPE location, YYLTYPE name_location): base(parent, method_id, location, name_location) { }
internal Scope(Scope parent_scope, YYLTYPE location) : base(location) { this.parent_scope = parent_scope; this.block_parent = null; }
internal BLOCK(Scope current, YYLTYPE location) : base(current, location) { this.block_parent = current; }
internal virtual void Init(YYLTYPE location, params object[] inputs) { this.body = (Node)inputs[0]; this.location = location; }
internal override void Init(YYLTYPE location, params object[] input) { this.location = location; this.args = (LVALUE)input[0]; body = (Node)input[1]; Node list = this.args; if (list == null) arity = -1; else { arity = 0; if (list is MLHS) list = ((MLHS)list).elements; while (list != null) { arity++; if (list is LHS_STAR) arity = -arity; list = (LVALUE)list.nd_next; } } }