Beispiel #1
0
        public ForLoopExpression(LexicalScope/*!*/ definedScope, Parameters/*!*/ variables, Expression/*!*/ list, Statements body, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope, variables, list);

            _block = new BlockDefinition(definedScope, variables, body, location);
            _list = list;
        }
Beispiel #2
0
        public BlockDefinition(LexicalScope/*!*/ definedScope, Parameters parameters, Statements/*!*/ body, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope, body);

            _definedScope = definedScope;
            _body = body;
            _parameters = parameters ?? Parameters.Empty; 
        }
Beispiel #3
0
        public MethodDefinition(LexicalScope/*!*/ definedScope, Expression target, string/*!*/ name, Parameters parameters, Body/*!*/ body, 
            SourceSpan location)
            : base(definedScope, body, location) {
            Assert.NotNull(name);

            _target = target;
            _name = name;
            _parameters = parameters ?? Parameters.Empty;
        }
Beispiel #4
0
        public MethodDefinition(LexicalScope/*!*/ definedScope, Expression target, string/*!*/ name, Parameters parameters, Body/*!*/ body, 
            SourceSpan location)
            : base(definedScope, body, location)
        {
            Assert.NotNull(name);

            // only for-loop block might use other than local variable for unsplat:
            Debug.Assert(parameters.Unsplat == null || parameters.Unsplat is LocalVariable);

            _target = target;
            _name = name;
            _parameters = parameters ?? Parameters.Empty;
        }
Beispiel #5
0
        public void EnterSourceUnit(
            ScopeBuilder/*!*/ locals,
            MSA.Expression/*!*/ selfParameter,
            MSA.ParameterExpression/*!*/ runtimeScopeVariable,
            MSA.Expression blockParameter,
            string methodName,
            Parameters parameters) {
            Assert.NotNull(locals, selfParameter, runtimeScopeVariable);

            Debug.Assert(_currentElement == null && _currentLoop == null && _currentRescue == null &&
                _currentVariableScope == null && _currentModule == null && _currentBlock == null && _currentMethod == null);

            EnterMethodDefinition(
                locals,
                selfParameter,
                runtimeScopeVariable,
                blockParameter,
                methodName,
                parameters);
        }
Beispiel #6
0
        public void EnterMethodDefinition(
            ScopeBuilder/*!*/ locals, 
            MSA.Expression/*!*/ selfParameter,
            MSA.ParameterExpression/*!*/ runtimeScopeVariable,
            MSA.Expression blockParameter,
            string/*!*/ methodName,
            Parameters parameters) {
            Assert.NotNull(locals, selfParameter, runtimeScopeVariable);

            MethodScope method = new MethodScope(
                locals,
                selfParameter, 
                runtimeScopeVariable, 
                blockParameter, 
                methodName, 
                parameters
            );

            method.Parent = _currentElement;
            method.ParentRescue = _currentRescue;
            method.ParentLoop = _currentLoop;
            method.ParentBlock = _currentBlock;
            method.ParentVariableScope = _currentVariableScope;
            method.ParentMethod = _currentMethod;

            _currentElement = method;
            _currentRescue = null;
            _currentLoop = null;
            _currentBlock = null;
            _currentVariableScope = method;
            _currentMethod = method;
        }
Beispiel #7
0
            public MethodScope(
                ScopeBuilder/*!*/ builder,
                MSA.Expression/*!*/ selfVariable,
                MSA.ParameterExpression/*!*/ runtimeScopeVariable,
                MSA.Expression blockVariable, 
                string methodName, 
                Parameters parameters)
                : base(builder, selfVariable, runtimeScopeVariable) {

                _blockVariable = blockVariable;
                _methodName = methodName;
                _parameters = parameters;
            }
 public virtual void Exit(Parameters/*!*/ node) { }
 public virtual bool Enter(Parameters/*!*/ node) { return true; }
Beispiel #10
0
            public MethodScope(
                ScopeBuilder/*!*/ builder, 
                MSA.Expression/*!*/ selfVariable, 
                MSA.Expression/*!*/ runtimeScopeVariable,
                MSA.Expression blockVariable, 
                MSA.Expression/*!*/ rfcVariable,
                MSA.Expression currentMethodVariable, 
                string methodName, 
                Parameters parameters)
                : base(builder, selfVariable, runtimeScopeVariable) {

                Assert.NotNull(rfcVariable);
                _blockVariable = blockVariable;
                _rfcVariable = rfcVariable;
                _methodName = methodName;
                _parameters = parameters;
                _currentMethodVariable = currentMethodVariable;
            }
Beispiel #11
0
		/// <summary>
		/// Converts the Parameters object into a list of LocalVariables
		/// </summary>
		List<LocalVariable> GetParameterVariables(Parameters parameters)
		{
			List<LocalVariable> variables = new List<LocalVariable>();
			if (parameters.Mandatory != null) {
				foreach (LocalVariable variable in parameters.Mandatory) {
					variables.Add(variable);
				}
			}
			
			if (parameters.Optional != null) {
				foreach (SimpleAssignmentExpression expression in parameters.Optional) {
					LocalVariable optionalVariable = expression.Left as LocalVariable;
					if (optionalVariable != null) {
						variables.Add(optionalVariable);
					}
				}
			}
			return variables;			
		}
Beispiel #12
0
		/// <summary>
		/// Converts from Ruby AST expressions to parameters.
		/// </summary>
		IParameter[] ConvertParameters(Parameters parameters)
		{
			List<IParameter> convertedParameters = new List<IParameter>();
			foreach (LocalVariable variable in GetParameterVariables(parameters)) {
				DefaultParameter parameter = new DefaultParameter(variable.Name, null, new DomRegion());
				convertedParameters.Add(parameter);
			}
			return convertedParameters.ToArray();
		}
Beispiel #13
0
 public virtual void Exit(Parameters /*!*/ node)
 {
 }
Beispiel #14
0
 public virtual bool Enter(Parameters /*!*/ node)
 {
     return(true);
 }