public WithScope(WithScope parent, IIdentifier identifier) { if (identifier == null) throw new ArgumentNullException("identifier"); Parent = parent; Identifier = identifier; }
public BuilderWithScope(BuilderWithScope parent, IIdentifier identifier, Scope scope) { Parent = parent; WithScope = new WithScope(parent != null ? parent.WithScope : null, identifier); Scope = scope; }
private BoundIf BuildGetWithScope(BlockBuilder builder, WithScope withScope, IIdentifier fallback, BoundTemporary result, BoundTemporary withTarget) { var withLocal = builder.CreateTemporary(); builder.Add(new BoundSetVariable( withLocal, new BoundGetVariable(_withIdentifiers[withScope.Identifier]), SourceLocation.Missing )); var getter = new BlockBuilder(this); if (withTarget != null) { getter.Add(new BoundSetVariable( withTarget, new BoundGetVariable(withLocal), SourceLocation.Missing )); } getter.Add(new BoundSetVariable( result, BuildGetMember( new BoundGetVariable(withLocal), BoundConstant.Create(fallback.Name) ), SourceLocation.Missing )); BoundBlock @else; if (withScope.Parent == null) { @else = BuildBlock(new BoundSetVariable( result, BuildGet( fallback, null ), SourceLocation.Missing )); } else { @else = BuildBlock(BuildGetWithScope( builder, withScope.Parent, fallback, result, withTarget )); } return new BoundIf( new BoundHasMember( new BoundGetVariable(withLocal), fallback.Name ), getter.BuildBlock(SourceLocation.Missing), @else, SourceLocation.Missing ); }
private BoundIf BuildSetWithScope(BlockBuilder builder, WithScope withScope, IIdentifier fallback, BoundTemporary value) { var withLocal = builder.CreateTemporary(); builder.Add(new BoundSetVariable( withLocal, new BoundGetVariable(_withIdentifiers[withScope.Identifier]), SourceLocation.Missing )); var setter = new BoundSetMember( new BoundGetVariable(withLocal), BoundConstant.Create(fallback.Name), new BoundGetVariable(value), SourceLocation.Missing ); BoundBlock @else; if (withScope.Parent == null) { @else = BuildBlock(BuildSet( fallback, new BoundGetVariable(value) )); } else { @else = BuildBlock(BuildSetWithScope( builder, withScope.Parent, fallback, value )); } return new BoundIf( new BoundHasMember( new BoundGetVariable(withLocal), fallback.Name ), BuildBlock(setter), @else, SourceLocation.Missing ); }
public ScopedIdentifier(WithScope withScope, IIdentifier fallback) { WithScope = withScope; Fallback = fallback; }