public VariableScope(ScopeBuilder /*!*/ locals, MSA.Expression /*!*/ selfVariable, MSA.Expression /*!*/ runtimeScopeVariable) { Assert.NotNull(selfVariable, runtimeScopeVariable); _builder = locals; _runtimeScopeVariable = runtimeScopeVariable; _selfVariable = selfVariable; }
public RescueScope(MSA.Expression /*!*/ retryingVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel) { Assert.NotNull(retryingVariable, breakLabel, continueLabel); _retryingVariable = retryingVariable; _breakLabel = breakLabel; _continueLabel = continueLabel; }
public void EnterSourceUnit( ScopeBuilder /*!*/ locals, MSA.Expression /*!*/ selfParameter, MSA.Expression /*!*/ runtimeScopeVariable, MSA.Expression blockParameter, MSA.Expression /*!*/ rfcVariable, MSA.Expression currentMethodVariable, string methodName, Parameters parameters) { Assert.NotNull(locals, selfParameter, runtimeScopeVariable, rfcVariable); Debug.Assert(_currentElement == null && _currentLoop == null && _currentRescue == null && _currentVariableScope == null && _currentModule == null && _currentBlock == null && _currentMethod == null); EnterMethodDefinition( locals, selfParameter, runtimeScopeVariable, blockParameter, rfcVariable, currentMethodVariable, methodName, parameters); }
private MSA.Expression /*!*/ TransformRead(AstGenerator /*!*/ gen, int /*!*/ opKind) { MSA.Expression transformedName = TransformName(gen); MSA.Expression transformedQualifier; switch (TransformQualifier(gen, out transformedQualifier)) { case StaticScopeKind.Global: return((opKind == OpGet ? Methods.GetGlobalConstant : Methods.IsDefinedGlobalConstant). OpCall(gen.CurrentScopeVariable, transformedName)); case StaticScopeKind.EnclosingModule: return((opKind == OpGet ? Methods.GetUnqualifiedConstant : Methods.IsDefinedUnqualifiedConstant). OpCall(gen.CurrentScopeVariable, transformedName)); case StaticScopeKind.Explicit: if (opKind == OpGet) { return(Methods.GetQualifiedConstant.OpCall(AstFactory.Box(transformedQualifier), gen.CurrentScopeVariable, transformedName)); } else { return(gen.TryCatchAny( Methods.IsDefinedQualifiedConstant.OpCall(AstFactory.Box(transformedQualifier), gen.CurrentScopeVariable, transformedName), Ast.Constant(false) )); } } throw Assert.Unreachable; }
internal static MSA.Expression /*!*/ TransformRead(AstGenerator /*!*/ gen, List <MSA.Expression> /*!*/ rightValues, MSA.Expression splattedValue, bool doSplat) { Assert.NotNull(gen, rightValues); MSA.Expression result; // We need to distinguish various special cases here. // For parallel assignment specification, see "Ruby Language.docx/Runtime/Parallel Assignment". // R(0,*)? bool rightNoneSplat = rightValues.Count == 0 && splattedValue != null; // R(1,-)? bool rightOneNone = rightValues.Count == 1 && splattedValue == null; if (rightNoneSplat) { result = (doSplat ? Methods.Splat : Methods.Unsplat).OpCall(AstFactory.Box(splattedValue)); } else if (rightOneNone && doSplat) { result = rightValues[0]; } else { result = Methods.MakeArrayOpCall(rightValues); if (splattedValue != null) { result = Methods.SplatAppend.OpCall(result, AstFactory.Box(splattedValue)); } } return(result); }
internal StaticScopeKind TransformQualifier(AstGenerator /*!*/ gen, out MSA.Expression transformedQualifier) { if (_qualifier != null) { Debug.Assert(_explicitlyBound); // qualifier.Foo transformedQualifier = _qualifier.TransformRead(gen); return(StaticScopeKind.Explicit); } else if (_explicitlyBound) { // ::Foo transformedQualifier = null; return(StaticScopeKind.Global); } else if (gen.CurrentModule != null) { // statically (lexically) implicitly bound to the enclosing module: transformedQualifier = gen.CurrentModule.SelfVariable; // TODO: remove, should be retrieved from code context/scope return(StaticScopeKind.EnclosingModule); } else { // statically (lexically) implicitly bound to top declaring module: transformedQualifier = null; return(StaticScopeKind.EnclosingModule); } }
public LoopScope(MSA.Expression /*!*/ redoVariable, MSA.Expression /*!*/ resultVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel) { Assert.NotNull(redoVariable, resultVariable, breakLabel, continueLabel); _redoVariable = redoVariable; _resultVariable = resultVariable; _breakLabel = breakLabel; _continueLabel = continueLabel; }
public BlockScope(ScopeBuilder /*!*/ builder, MSA.Expression /*!*/ selfVariable, MSA.Expression /*!*/ runtimeScopeVariable, MSA.Expression /*!*/ bfcVariable, MSA.LabelTarget /*!*/ redoLabel) : base(builder, selfVariable, runtimeScopeVariable) { Assert.NotNull(bfcVariable, redoLabel); _bfcVariable = bfcVariable; _redoLabel = redoLabel; }
internal MSA.Expression /*!*/ AddDebugInfo(MSA.Expression /*!*/ expression, SourceSpan location) { if (_document == null || !location.IsValid) { return(expression); } return(MSA.Expression.DebugInfo(expression, _document, location.Start.Line, location.Start.Column, location.End.Line, location.End.Column)); }
internal sealed override MSA.Expression /*!*/ TransformRead(AstGenerator /*!*/ gen) { string debugString = (IsSingletonDeclaration) ? "SINGLETON" : ((this is ClassDeclaration) ? "CLASS" : "MODULE") + " " + QualifiedName.Name; ScopeBuilder outerLocals = gen.CurrentScope; // definition needs to take place outside the defined lexical scope: MSA.Expression definition = MakeDefinitionExpression(gen); MSA.Expression selfVariable = outerLocals.DefineHiddenVariable("#module", typeof(RubyModule)); MSA.Expression rfcVariable = gen.CurrentRfcVariable; MSA.Expression parentScope = gen.CurrentScopeVariable; // inner locals: ScopeBuilder scope = new ScopeBuilder(); MSA.Expression scopeVariable = scope.DefineHiddenVariable("#scope", typeof(RubyScope)); gen.EnterModuleDefinition( scope, selfVariable, scopeVariable, IsSingletonDeclaration ); // first, transform locals defined within the module body: DefinedScope.TransformLocals(scope); // second, transform body: MSA.Expression transformedBody = Body.TransformRead(gen); // outer local: MSA.Expression resultVariable = outerLocals.DefineHiddenVariable("#result", transformedBody.Type); // begin with new scope // self = DefineModule/Class(... parent scope here ...) // <body> // end MSA.Expression result = AstFactory.Block( gen.DebugMarker(debugString), Ast.Assign(selfVariable, definition), scope.CreateScope( Ast.Block( Ast.Assign(scopeVariable, Methods.CreateModuleScope.OpCall(scope.VisibleVariables(), parentScope, rfcVariable, selfVariable)), Ast.Assign(resultVariable, transformedBody), Ast.Empty() ) ), gen.DebugMarker("END OF " + debugString), resultVariable ); gen.LeaveModuleDefinition(); return(result); }
public void EnterLoop(MSA.Expression /*!*/ redoVariable, MSA.Expression /*!*/ resultVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel) { Assert.NotNull(redoVariable, resultVariable, breakLabel, continueLabel); LoopScope loop = new LoopScope(redoVariable, resultVariable, breakLabel, continueLabel); loop.Parent = _currentElement; loop.ParentLoop = _currentLoop; _currentElement = _currentLoop = loop; }
public void EnterRescueClause(MSA.Expression /*!*/ retryingVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel) { Assert.NotNull(retryingVariable, breakLabel, continueLabel); RescueScope body = new RescueScope(retryingVariable, breakLabel, continueLabel); body.Parent = _currentElement; body.ParentRescue = _currentRescue; _currentElement = _currentRescue = body; }
internal MSA.Expression /*!*/ AddReturnTarget(MSA.Expression /*!*/ expression) { if (expression.Type != typeof(object)) { expression = AstFactory.Box(expression); } if (_returnLabel != null) { expression = Ast.Label(_returnLabel, expression); _returnLabel = null; } return(expression); }
internal static MSA.Expression /*!*/ TransformRead(AstGenerator /*!*/ gen, MSA.Expression /*!*/ left, MSA.Expression /*!*/ right) { MSA.ParameterExpression temp; MSA.Expression result = AstUtils.CoalesceFalse( AstFactory.Box(left), AstFactory.Box(right), Methods.IsTrue, out temp ); gen.CurrentScope.AddHidden(temp); return(result); }
internal MSA.Expression /*!*/ TryCatchAny(MSA.Expression /*!*/ tryBody, MSA.Expression /*!*/ catchBody) { var variable = CurrentScope.DefineHiddenVariable("#value", tryBody.Type); return (Ast.Block( Ast.TryCatch( Ast.Assign(variable, tryBody), Ast.Catch(typeof(Exception), Ast.Assign(variable, catchBody) ) ), variable )); }
internal MSA.Expression /*!*/ TransformToYield(AstGenerator /*!*/ gen, MSA.Expression /*!*/ bfcVariable, MSA.Expression /*!*/ selfExpression) { var args = (_expressions != null) ? gen.TranformExpressions(_expressions) : new List <MSA.Expression>(); if (_maplets != null) { args.Add(gen.TransformToHashConstructor(_maplets)); } return(AstFactory.YieldExpression( args, (_array != null) ? _array.TransformRead(gen) : null, // splatted argument null, // rhs argument bfcVariable, selfExpression )); }
internal MSA.Expression /*!*/ Return(MSA.Expression /*!*/ expression) { MSA.LabelTarget returnLabel = ReturnLabel; if (returnLabel.Type != typeof(void) && expression.Type == typeof(void)) { expression = Ast.Block(expression, Ast.Constant(null, typeof(object))); } else if (returnLabel.Type != expression.Type) { if (!CanAssign(returnLabel.Type, expression.Type)) { // Add conversion step to the AST expression = Ast.Convert(expression, returnLabel.Type); } } return(Ast.Return(returnLabel, expression)); }
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; }
public void EnterModuleDefinition( ScopeBuilder /*!*/ locals, MSA.Expression /*!*/ selfVariable, MSA.Expression /*!*/ runtimeScopeVariable, bool isSingleton) { Assert.NotNull(locals, selfVariable, runtimeScopeVariable); ModuleScope module = new ModuleScope(locals, selfVariable, runtimeScopeVariable, isSingleton); module.Parent = _currentElement; module.ParentVariableScope = _currentVariableScope; module.ParentModule = _currentModule; _currentElement = module; _currentVariableScope = module; _currentModule = module; }
internal virtual MSA.Expression /*!*/ MakeDefinitionExpression(AstGenerator /*!*/ gen) { MSA.Expression transformedQualifier; MSA.Expression name = QualifiedName.TransformName(gen); switch (QualifiedName.TransformQualifier(gen, out transformedQualifier)) { case StaticScopeKind.Global: return(Methods.DefineGlobalModule.OpCall(gen.CurrentScopeVariable, name)); case StaticScopeKind.EnclosingModule: return(Methods.DefineNestedModule.OpCall(gen.CurrentScopeVariable, name)); case StaticScopeKind.Explicit: return(Methods.DefineModule.OpCall(gen.CurrentScopeVariable, AstFactory.Box(transformedQualifier), name)); } throw Assert.Unreachable; }
internal override MSA.Expression /*!*/ TransformWriteVariable(AstGenerator /*!*/ gen, MSA.Expression /*!*/ rightValue) { MSA.Expression transformedName = TransformName(gen); MSA.Expression transformedQualifier; switch (TransformQualifier(gen, out transformedQualifier)) { case StaticScopeKind.Global: return(Methods.SetGlobalConstant.OpCall(AstFactory.Box(rightValue), gen.CurrentScopeVariable, transformedName)); case StaticScopeKind.EnclosingModule: return(Methods.SetUnqualifiedConstant.OpCall(AstFactory.Box(rightValue), gen.CurrentScopeVariable, transformedName)); case StaticScopeKind.Explicit: return(Methods.SetQualifiedConstant.OpCall(AstFactory.Box(rightValue), transformedQualifier, gen.CurrentScopeVariable, transformedName)); } throw Assert.Unreachable; }
internal override MSA.Expression /*!*/ MakeDefinitionExpression(AstGenerator /*!*/ gen) { MSA.Expression transformedQualifier; MSA.Expression name = QualifiedName.TransformName(gen); MSA.Expression transformedSuper = (_superClass != null) ? AstFactory.Box(_superClass.TransformRead(gen)) : Ast.Constant(null); switch (QualifiedName.TransformQualifier(gen, out transformedQualifier)) { case StaticScopeKind.Global: return(Methods.DefineGlobalClass.OpCall(gen.CurrentScopeVariable, name, transformedSuper)); case StaticScopeKind.EnclosingModule: return(Methods.DefineNestedClass.OpCall(gen.CurrentScopeVariable, name, transformedSuper)); case StaticScopeKind.Explicit: return(Methods.DefineClass.OpCall(gen.CurrentScopeVariable, transformedQualifier, name, transformedSuper)); } throw Assert.Unreachable; }
internal MSA.Expression /*!*/ TransformStatementsToExpression(List <Expression> statements) { if (statements == null || statements.Count == 0) { return(Ast.Constant(null)); } if (statements.Count == 1) { return(statements[0].TransformRead(this)); } var result = new MSA.Expression[statements.Count]; for (int i = 0; i < result.Length - 1; i++) { result[i] = statements[i].Transform(this); } result[result.Length - 1] = statements[statements.Count - 1].TransformRead(this); return(Ast.Block(new ReadOnlyCollection <MSA.Expression>(result))); }
internal static MSA.Expression /*!*/ MakeCallWithBlockRetryable(AstGenerator /*!*/ gen, MSA.Expression /*!*/ invoke, MSA.Expression blockArgVariable, MSA.Expression transformedBlock, bool isBlockDefinition) { Assert.NotNull(invoke); Debug.Assert((blockArgVariable == null) == (transformedBlock == null)); // see Ruby Language.doc/Control Flow Implementation/Method Call With a Block MSA.Expression resultVariable = gen.CurrentScope.DefineHiddenVariable("#method-result", typeof(object)); MSA.ParameterExpression evalUnwinder = gen.CurrentScope.DefineHiddenVariable("#unwinder", typeof(EvalUnwinder)); MSA.LabelTarget label = Ast.Label(); return(AstFactory.Block( Ast.Assign(blockArgVariable, Ast.Convert(transformedBlock, blockArgVariable.Type)), AstFactory.Infinite(label, null, (!isBlockDefinition) ? (MSA.Expression)Ast.Empty() : (MSA.Expression)Methods.InitializeBlock.OpCall(blockArgVariable), AstUtils.Try( Ast.Assign(resultVariable, invoke) ).Catch(evalUnwinder, Ast.Assign( resultVariable, Ast.Field(evalUnwinder, EvalUnwinder.ReturnValueField) ) ), // if result != RetrySingleton then break end AstUtils.Unless(Methods.IsRetrySingleton.OpCall(AstFactory.Box(resultVariable)), Ast.Break(label)), // if blockParam == #block then retry end (gen.CurrentMethod.IsTopLevelCode) ? Ast.Empty() : AstUtils.IfThen(Ast.Equal(gen.MakeMethodBlockParameterRead(), blockArgVariable), RetryStatement.TransformRetry(gen)) ), resultVariable )); }
public void EnterMethodDefinition( ScopeBuilder /*!*/ locals, MSA.Expression /*!*/ selfParameter, MSA.Expression /*!*/ runtimeScopeVariable, MSA.Expression blockParameter, MSA.Expression /*!*/ rfcVariable, MSA.Expression currentMethodVariable, string /*!*/ methodName, Parameters parameters) { Assert.NotNull(locals, selfParameter, runtimeScopeVariable, rfcVariable); MethodScope method = new MethodScope( locals, selfParameter, runtimeScopeVariable, blockParameter, rfcVariable, currentMethodVariable, 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; }
public void EnterBlockDefinition( ScopeBuilder /*!*/ locals, MSA.Expression /*!*/ bfcVariable, MSA.Expression /*!*/ selfVariable, MSA.Expression /*!*/ runtimeScopeVariable, MSA.LabelTarget /*!*/ redoLabel) { Assert.NotNull(locals, bfcVariable, selfVariable); Assert.NotNull(redoLabel); BlockScope block = new BlockScope(locals, selfVariable, runtimeScopeVariable, bfcVariable, redoLabel); block.Parent = _currentElement; block.ParentRescue = _currentRescue; block.ParentLoop = _currentLoop; block.ParentBlock = _currentBlock; block.ParentVariableScope = _currentVariableScope; _currentElement = block; _currentRescue = null; _currentLoop = null; _currentBlock = block; _currentVariableScope = block; }
public VariableScope(ScopeBuilder/*!*/ locals, MSA.Expression/*!*/ selfVariable, MSA.Expression/*!*/ runtimeScopeVariable) { Assert.NotNull(selfVariable, runtimeScopeVariable); _builder = locals; _runtimeScopeVariable = runtimeScopeVariable; _selfVariable = selfVariable; }
public RescueScope(MSA.Expression/*!*/ retryingVariable, MSA.LabelTarget/*!*/ breakLabel, MSA.LabelTarget/*!*/ continueLabel) { Assert.NotNull(retryingVariable, breakLabel, continueLabel); _retryingVariable = retryingVariable; _breakLabel = breakLabel; _continueLabel = continueLabel; }
internal MSA.Expression/*!*/ TransformStatementsToExpression(List<Expression> statements) { if (statements == null || statements.Count == 0) { return Ast.Constant(null); } if (statements.Count == 1) { return statements[0].TransformRead(this); } var result = new MSA.Expression[statements.Count]; for (int i = 0; i < result.Length - 1; i++) { result[i] = statements[i].Transform(this); } result[result.Length - 1] = statements[statements.Count - 1].TransformRead(this); return Ast.Block(new ReadOnlyCollection<MSA.Expression>(result)); }
internal static MSA.Expression /*!*/ TransformConcatentation(AstGenerator /*!*/ gen, List <Expression> /*!*/ parts, Func <string, MethodInfo> /*!*/ opFactory, MSA.Expression additionalArg) { var opSuffix = new StringBuilder(Math.Min(parts.Count, 4)); List <MSA.Expression> merged = ConcatLiteralsAndTransform(gen, parts, opSuffix); if (merged.Count <= RubyOps.MakeStringParamCount) { if (merged.Count == 0) { merged.Add(Ast.Constant(String.Empty)); opSuffix.Append(RubyOps.SuffixBinary); } if (opSuffix.IndexOf(RubyOps.SuffixEncoded) != -1) { merged.Add(Ast.Constant(RubyEncoding.GetCodePage(gen.Encoding))); } if (additionalArg != null) { merged.Add(additionalArg); } return(opFactory(opSuffix.ToString()).OpCall(merged)); } else { var paramArray = Ast.NewArrayInit(typeof(object), merged); var codePage = Ast.Constant(RubyEncoding.GetCodePage(gen.Encoding)); return((additionalArg != null) ? opFactory("N").OpCall(paramArray, codePage, additionalArg) : opFactory("N").OpCall(paramArray, codePage)); } }
internal MSA.Expression/*!*/ TransformStatementsToExpression(Statements statements) { if (statements == null || statements.Count == 0) { return AstUtils.Constant(null); } if (statements.Count == 1) { return statements.First.TransformRead(this); } var result = new MSA.Expression[statements.Count]; int i = 0; foreach (var statement in statements.AllButLast) { result[i++] = statement.Transform(this); } result[result.Length - 1] = statements.Last.TransformRead(this); return Ast.Block(new ReadOnlyCollection<MSA.Expression>(result)); }
internal MSA.Expression /*!*/ DebugMark(MSA.Expression /*!*/ expression, string /*!*/ marker) { return(_debugCompiler ? AstFactory.Block(Methods.X.OpCall(Ast.Constant(marker)), expression) : expression); }
public RescueScope(MSA.Expression/*!*/ retryingVariable, MSA.LabelTarget/*!*/ retryLabel) { Assert.NotNull(retryingVariable, retryLabel); _retryingVariable = retryingVariable; _retryLabel = retryLabel; }
internal MSA.Expression/*!*/ TransformStatements(MSA.Expression prologue, Statements/*!*/ statements, MSA.Expression epilogue, ResultOperation resultOperation) { Assert.NotNull(statements); int count = statements.Count + (prologue != null ? 1 : 0) + (epilogue != null ? 1 : 0); if (count == 0) { if (resultOperation.IsIgnore) { return AstUtils.Empty(); } else if (resultOperation.Variable != null) { return Ast.Assign(resultOperation.Variable, AstUtils.Constant(null, resultOperation.Variable.Type)); } else { return Ast.Return(CurrentFrame.ReturnLabel, AstUtils.Constant(null)); } } else if (count == 1) { if (prologue != null) { return prologue; } if (epilogue != null) { return epilogue; } if (resultOperation.IsIgnore) { return statements.First.Transform(this); } else { return statements.First.TransformResult(this, resultOperation); } } else { var result = new MSA.Expression[count + 1]; int resultIndex = 0; if (prologue != null) { result[resultIndex++] = prologue; } // transform all but the last statement if it is an expression stmt: foreach (var statement in statements.AllButLast) { result[resultIndex++] = statement.Transform(this); } if (statements.Count > 0) { if (resultOperation.IsIgnore) { result[resultIndex++] = statements.Last.Transform(this); } else { result[resultIndex++] = statements.Last.TransformResult(this, resultOperation); } } if (epilogue != null) { result[resultIndex++] = epilogue; } result[resultIndex++] = AstUtils.Empty(); Debug.Assert(resultIndex == result.Length); return Ast.Block(new ReadOnlyCollection<MSA.Expression>(result)); } }
internal MSA.Expression /*!*/ AddReturnTarget(MSA.Expression /*!*/ expression) { return(CurrentFrame.AddReturnTarget(expression)); }
public BlockScope(ScopeBuilder/*!*/ builder, MSA.Expression/*!*/ selfVariable, MSA.Expression/*!*/ runtimeScopeVariable, MSA.Expression/*!*/ bfcVariable, MSA.LabelTarget/*!*/ redoLabel) : base(builder, selfVariable, runtimeScopeVariable) { Assert.NotNull(bfcVariable, redoLabel); _bfcVariable = bfcVariable; _redoLabel = redoLabel; }
internal MSA.Expression /*!*/ TransformStatements(MSA.Expression prologue, List <Expression> /*!*/ statements, MSA.Expression epilogue, ResultOperation resultOperation) { Assert.NotNullItems(statements); int count = statements.Count + (prologue != null ? 1 : 0) + (epilogue != null ? 1 : 0); if (count == 0) { if (resultOperation.IsIgnore) { return(Ast.Empty()); } else if (resultOperation.Variable != null) { return(Ast.Assign(resultOperation.Variable, Ast.Constant(null, resultOperation.Variable.Type))); } else { return(Ast.Return(CurrentFrame.ReturnLabel, Ast.Constant(null))); } } else if (count == 1) { if (prologue != null) { return(prologue); } if (epilogue != null) { return(epilogue); } if (resultOperation.IsIgnore) { return(statements[0].Transform(this)); } else { return(statements[0].TransformResult(this, resultOperation)); } } else { var result = new MSA.Expression[count + 1]; int resultIndex = 0; if (prologue != null) { result[resultIndex++] = prologue; } // transform all but the last statement if it is an expression stmt: for (int i = 0; i < statements.Count - 1; i++) { result[resultIndex++] = statements[i].Transform(this); } if (statements.Count > 0) { if (resultOperation.IsIgnore) { result[resultIndex++] = statements[statements.Count - 1].Transform(this); } else { result[resultIndex++] = statements[statements.Count - 1].TransformResult(this, resultOperation); } } if (epilogue != null) { result[resultIndex++] = epilogue; } result[resultIndex++] = MSA.Expression.Empty(); Debug.Assert(resultIndex == result.Length); return(Ast.Block(new ReadOnlyCollection <MSA.Expression>(result))); } }
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; }
public LoopScope(MSA.Expression/*!*/ redoVariable, MSA.Expression/*!*/ resultVariable, MSA.LabelTarget/*!*/ breakLabel, MSA.LabelTarget/*!*/ continueLabel) { Assert.NotNull(redoVariable, resultVariable, breakLabel, continueLabel); _redoVariable = redoVariable; _resultVariable = resultVariable; _breakLabel = breakLabel; _continueLabel = continueLabel; }