private AstParameters /*!*/ DefineParameters(out MSA.ParameterExpression /*!*/ selfVariable, out MSA.ParameterExpression /*!*/ blockParamVariable) { var parameters = new AstParameters( HiddenParameterCount + (HasFormalParametersInArray ? 1 : _parameters.LeftValues.Count) + (HasUnsplatParameter ? 1 : 0) ); // hidden parameters: // #proc must be the first one - it is used as instance target for method invocation: parameters.Add(blockParamVariable = Ast.Parameter(typeof(BlockParam), "#proc")); parameters.Add(selfVariable = Ast.Parameter(typeof(object), "#self")); if (HasFormalParametersInArray) { parameters.Add(Ast.Parameter(typeof(object[]), "#parameters")); } else { for (int i = 0; i < _parameters.LeftValues.Count; i++) { parameters.Add(Ast.Parameter(typeof(object), "#" + i)); } } if (HasUnsplatParameter) { parameters.Add(Ast.Parameter(typeof(RubyArray), "#array")); } return(parameters); }
private ScopeBuilder/*!*/ DefineLocals(out AstParameters/*!*/ parameters) { parameters = new AstParameters( HiddenParameterCount + (_parameters.Mandatory != null ? _parameters.Mandatory.Count : 0) + (_parameters.Optional != null ? _parameters.Optional.Count : 0) + (_parameters.Array != null ? 1 : 0) ); int closureIndex = 0; int firstClosureParam = 1; parameters.Add(Ast.Parameter(typeof(object), "#self")); if (_parameters.Block != null) { parameters.Add(Ast.Parameter(typeof(Proc), _parameters.Block.Name)); _parameters.Block.SetClosureIndex(closureIndex++); } else { parameters.Add(Ast.Parameter(typeof(Proc), "#block")); firstClosureParam++; } if (_parameters.Mandatory != null) { foreach (var param in _parameters.Mandatory) { parameters.Add(Ast.Parameter(typeof(object), param.Name)); param.SetClosureIndex(closureIndex++); } } if (_parameters.Optional != null) { foreach (var lvalue in _parameters.Optional) { var param = (LocalVariable)lvalue.Left; parameters.Add(Ast.Parameter(typeof(object), param.Name)); param.SetClosureIndex(closureIndex++); } } if (_parameters.Array != null) { parameters.Add(Ast.Parameter(typeof(object), _parameters.Array.Name)); _parameters.Array.SetClosureIndex(closureIndex++); } // allocate closure slots for locals: int localCount = DefinedScope.AllocateClosureSlotsForLocals(closureIndex); return new ScopeBuilder(parameters, firstClosureParam, localCount, null, DefinedScope); }
private AstParameters /*!*/ DefineParameters(out MSA.ParameterExpression /*!*/ selfVariable, out MSA.ParameterExpression /*!*/ blockParamVariable) { // Block signature: // <proc>, <self>, <leading-mandatory>, <trailing-mandatory>, <optional>, &<block>, *<unsplat> // or // <proc>, <self>, object[] { <leading-mandatory>, <trailing-mandatory>, <optional>, &<block> } *<unsplat>, var parameters = new AstParameters( HiddenParameterCount + (HasFormalParametersInArray ? 1 : ParameterCount) + (HasUnsplatParameter ? 1 : 0) ); // hidden parameters: // #proc must be the first one - it is used as instance target for method invocation: parameters.Add(blockParamVariable = Ast.Parameter(typeof(BlockParam), "#proc")); parameters.Add(selfVariable = Ast.Parameter(typeof(object), "#self")); if (HasFormalParametersInArray) { parameters.Add(Ast.Parameter(typeof(object[]), "#parameters")); } else { for (int i = 0; i < ParameterCount; i++) { parameters.Add(Ast.Parameter(typeof(object), "#" + i)); } } if (HasUnsplatParameter) { parameters.Add(Ast.Parameter(typeof(RubyArray), "#array")); } return(parameters); }
private ScopeBuilder /*!*/ DefineLocals(out AstParameters /*!*/ parameters) { parameters = new AstParameters( HiddenParameterCount + (_parameters.Mandatory != null ? _parameters.Mandatory.Count : 0) + (_parameters.Optional != null ? _parameters.Optional.Count : 0) + (_parameters.Array != null ? 1 : 0) ); int closureIndex = 0; int firstClosureParam = 1; parameters.Add(Ast.Parameter(typeof(object), "#self")); if (_parameters.Block != null) { parameters.Add(Ast.Parameter(typeof(Proc), _parameters.Block.Name)); _parameters.Block.SetClosureIndex(closureIndex++); } else { parameters.Add(Ast.Parameter(typeof(Proc), "#block")); firstClosureParam++; } if (_parameters.Mandatory != null) { foreach (var param in _parameters.Mandatory) { parameters.Add(Ast.Parameter(typeof(object), param.Name)); param.SetClosureIndex(closureIndex++); } } if (_parameters.Optional != null) { foreach (var lvalue in _parameters.Optional) { var param = (LocalVariable)lvalue.Left; parameters.Add(Ast.Parameter(typeof(object), param.Name)); param.SetClosureIndex(closureIndex++); } } if (_parameters.Array != null) { parameters.Add(Ast.Parameter(typeof(object), _parameters.Array.Name)); _parameters.Array.SetClosureIndex(closureIndex++); } // allocate closure slots for locals: int localCount = DefinedScope.AllocateClosureSlotsForLocals(closureIndex); return(new ScopeBuilder(parameters, firstClosureParam, localCount, null, DefinedScope)); }
public MSA.ParameterExpression /*!*/ AddHidden(MSA.ParameterExpression /*!*/ variable) { _hiddenVariables.Add(variable); return(variable); }
private AstParameters/*!*/ DefineParameters(out MSA.ParameterExpression/*!*/ selfVariable, out MSA.ParameterExpression/*!*/ blockParamVariable) { // Block signature: // <proc>, <self>, <leading-mandatory>, <trailing-mandatory>, <optional>, &<block>, *<unsplat> // or // <proc>, <self>, object[] { <leading-mandatory>, <trailing-mandatory>, <optional>, &<block> } *<unsplat>, var parameters = new AstParameters( HiddenParameterCount + (HasFormalParametersInArray ? 1 : ParameterCount) + (HasUnsplatParameter ? 1 : 0) + (HasProcParameter ? 1 : 0) ); // hidden parameters: // #proc must be the first one - it is used as instance target for method invocation: parameters.Add(blockParamVariable = Ast.Parameter(typeof(BlockParam), "#bp")); parameters.Add(selfVariable = Ast.Parameter(typeof(object), "#self")); if (HasFormalParametersInArray) { parameters.Add(Ast.Parameter(typeof(object[]), "#parameters")); } else { for (int i = 0; i < ParameterCount; i++) { parameters.Add(Ast.Parameter(typeof(object), "#" + i)); } } if (HasUnsplatParameter) { parameters.Add(Ast.Parameter(typeof(RubyArray), "#array")); } if (HasProcParameter) { parameters.Add(Ast.Parameter(typeof(Proc), "#proc")); } return parameters; }
private AstParameters/*!*/ DefineParameters(out MSA.ParameterExpression/*!*/ selfVariable, out MSA.ParameterExpression/*!*/ blockParamVariable) { var parameters = new AstParameters( HiddenParameterCount + (HasFormalParametersInArray ? 1 : _parameters.LeftValues.Count) + (HasUnsplatParameter ? 1 : 0) ); // hidden parameters: // #proc must be the first one - it is used as instance target for method invocation: parameters.Add(blockParamVariable = Ast.Parameter(typeof(BlockParam), "#proc")); parameters.Add(selfVariable = Ast.Parameter(typeof(object), "#self")); if (HasFormalParametersInArray) { parameters.Add(Ast.Parameter(typeof(object[]), "#parameters")); } else { for (int i = 0; i < _parameters.LeftValues.Count; i++) { parameters.Add(Ast.Parameter(typeof(object), "#" + i)); } } if (HasUnsplatParameter) { parameters.Add(Ast.Parameter(typeof(RubyArray), "#array")); } return parameters; }
private ScopeBuilder /*!*/ DefineLocals(out AstParameters /*!*/ parameters) { // Method signature: // <self>, &<block>, <leading-mandatory>, <trailing-mandatory>, <optional>, *<unsplat> parameters = new AstParameters( HiddenParameterCount + _parameters.Mandatory.Length + _parameters.Optional.Length + (_parameters.Unsplat != null ? 1 : 0) ); int closureIndex = 0; int firstClosureParam = 1; parameters.Add(Ast.Parameter(typeof(object), "#self")); if (_parameters.Block != null) { parameters.Add(Ast.Parameter(typeof(Proc), _parameters.Block.Name)); _parameters.Block.SetClosureIndex(closureIndex++); } else { parameters.Add(Ast.Parameter(typeof(Proc), "#block")); firstClosureParam++; } foreach (LeftValue lvalue in _parameters.Mandatory) { var param = lvalue as LocalVariable; if (param != null) { parameters.Add(Ast.Parameter(typeof(object), param.Name)); param.SetClosureIndex(closureIndex++); } else { // TODO: throw new NotSupportedException("TODO: compound parameters"); } } foreach (var lvalue in _parameters.Optional) { var param = (LocalVariable)lvalue.Left; parameters.Add(Ast.Parameter(typeof(object), param.Name)); param.SetClosureIndex(closureIndex++); } if (_parameters.Unsplat != null) { var unsplatLocal = (LocalVariable)_parameters.Unsplat; parameters.Add(Ast.Parameter(typeof(object), unsplatLocal.Name)); unsplatLocal.SetClosureIndex(closureIndex++); } // allocate closure slots for locals: int localCount = DefinedScope.AllocateClosureSlotsForLocals(closureIndex); return(new ScopeBuilder(parameters, firstClosureParam, localCount, null, DefinedScope)); }
/*!*/ private ScopeBuilder DefineLocals(out AstParameters/*!*/ parameters) { // Method signature: // <self>, &<block>, <leading-mandatory>, <trailing-mandatory>, <optional>, *<unsplat> parameters = new AstParameters( HiddenParameterCount + _parameters.Mandatory.Length + _parameters.Optional.Length + (_parameters.Unsplat != null ? 1 : 0) ); int closureIndex = 0; int firstClosureParam = 1; parameters.Add(Ast.Parameter(typeof(object), "#self")); if (_parameters.Block != null) { parameters.Add(Ast.Parameter(typeof(Proc), _parameters.Block.Name)); _parameters.Block.SetClosureIndex(closureIndex++); } else { parameters.Add(Ast.Parameter(typeof(Proc), "#block")); firstClosureParam++; } foreach (LeftValue lvalue in _parameters.Mandatory) { var param = lvalue as LocalVariable; if (param != null) { parameters.Add(Ast.Parameter(typeof(object), param.Name)); param.SetClosureIndex(closureIndex++); } else { // TODO: throw new NotSupportedException("TODO: compound parameters"); } } foreach (var lvalue in _parameters.Optional) { var param = (LocalVariable)lvalue.Left; parameters.Add(Ast.Parameter(typeof(object), param.Name)); param.SetClosureIndex(closureIndex++); } if (_parameters.Unsplat != null) { var unsplatLocal = (LocalVariable)_parameters.Unsplat; parameters.Add(Ast.Parameter(typeof(object), unsplatLocal.Name)); unsplatLocal.SetClosureIndex(closureIndex++); } // allocate closure slots for locals: int localCount = DefinedScope.AllocateClosureSlotsForLocals(closureIndex); return new ScopeBuilder(parameters, firstClosureParam, localCount, null, DefinedScope); }