public GotoStmt(Text.Span span, string/*!*/labelName, Text.Span nameSpan) : base(span) { Debug.Assert(!string.IsNullOrEmpty(labelName)); _labelName = new VariableName(labelName); _nameSpan = nameSpan; }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { var name = new VariableName(SassClassifierType.VariableReference); if (name.Parse(itemFactory, text, stream)) { Name = name; Children.Add(name); } return Children.Count > 0; }
public FormalParam(Position position, string/*!*/ name, object typeHint, bool passedByRef, Expression initValue, List<CustomAttribute> attributes) : base(position) { this.name = new VariableName(name); this.typeHint = typeHint; this.passedByRef = passedByRef; this.initValue = initValue; this.attributes = new CustomAttributes(attributes); this.resolvedTypeHint = null; }
public FormalParam(Text.Span span, string/*!*/ name, object typeHint, bool passedByRef, Expression initValue, List<CustomAttribute> attributes) : base(span) { Debug.Assert(typeHint == null || typeHint is PrimitiveTypeName || typeHint is GenericQualifiedName); this.name = new VariableName(name); this.typeHint = typeHint; this.passedByRef = passedByRef; this.initValue = initValue; if (attributes != null && attributes.Count != 0) this.Attributes = new CustomAttributes(attributes); this.TypeHintPosition = Text.Span.Invalid; }
BoundVariable CreateVariable(VariableName name, VariableKind kind, Func<BoundExpression> initializer) { switch (kind) { case VariableKind.LocalVariable: Debug.Assert(initializer == null); return new BoundLocal(new SourceLocalSymbol(_routine, name.Value, kind)); case VariableKind.StaticVariable: return new BoundStaticLocal(new SourceLocalSymbol(_routine, name.Value, kind), initializer?.Invoke()); case VariableKind.GlobalVariable: Debug.Assert(initializer == null); return new BoundGlobalVariable(name); default: Debug.Assert(initializer == null); throw Roslyn.Utilities.ExceptionUtilities.UnexpectedValue(kind); } }
public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream) { var name = new VariableName(SassClassifierType.VariableDefinition); if (name.Parse(itemFactory, text, stream)) { Name = name; Children.Add(name); } if (stream.Current.Type == TokenType.Colon) Colon = Children.AddCurrentAndAdvance(stream); while (!IsValueTerminator(Mode, stream)) { ParseItem item; if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out item)) { Values.Add(item); Children.Add(item); } } if (stream.Current.Type == TokenType.Bang) { var modifier = new DefaultModifier(); if (modifier.Parse(itemFactory, text, stream)) { Modifier = modifier; Children.Add(modifier); } else { Children.AddCurrentAndAdvance(stream); } } if (stream.Current.Type == TokenType.Semicolon) Semicolon = Children.AddCurrentAndAdvance(stream); return Children.Count > 0; }
public ConstantDecl(Text.Span span, string/*!*/ name, Expression/*!*/ initializer) : base(span) { this.name = new VariableName(name); this.initializer = initializer; }
/// <summary> /// Notify all listeners that a variable in the model has been changed. /// </summary> private void NotifyListeners(VariableName v, object oldValue, object newValue) { lock(this) { lock(listeners) { foreach (IEditorListener l in listeners) { l.ModelChanged(v, oldValue, newValue); } } } }
/// <summary> /// Used by full reflection. /// </summary> public PhpField(VariableName name, DPropertyDesc/*!*/ fieldDesc, FieldInfo/*!*/ fieldInfo, PropertyInfo exportedProperty) : base(fieldDesc, name) { Debug.Assert(fieldDesc is DPhpFieldDesc); this.realField = fieldInfo; this.exportedProperty = exportedProperty; this.hasInitialValue = realField.IsDefined(typeof(PhpHasInitValueAttribute), false); this.builder = null; this.implementor = DeclaringPhpType; }
/// <summary> /// Used by subclasses. /// </summary> protected KnownProperty(DPropertyDesc/*!*/ propertyDesc, VariableName name) : base(propertyDesc) { this.name = name; // TODO }
/// <summary> /// Used by full-reflect. /// </summary> public ClrField(VariableName/*!*/ name, ClrTypeDesc/*!*/ declaringType, PhpMemberAttributes memberAttributes, FieldInfo/*!*/ fieldInfo) : base(new DPropertyDesc(declaringType, memberAttributes), name) { this.fieldInfo = fieldInfo; }
/// <summary> /// Emits IL instructions that ensure that a static field is of <see cref="PhpObject"/> or <see cref="PhpArray"/> /// type. Handles the case when field name is known at compile time (see <see cref="AST.DirectStFldUse"/>). /// </summary> /// <param name="property">The corresponding <see cref="DProperty"/> or <B>null</B>.</param> /// <param name="typeRef">The class type reference (identifier index).</param> /// <param name="fieldName">The field name (identifier index).</param> /// <param name="ensureArray">Whether to ensure that static field is an array (or an object).</param> /// <remarks> /// Nothing is expected on the evaluation stack. A <see cref="PhpObject"/> or <see cref="DObject"/> is left /// on the evaluation stack or the last emitted instruction is unconditional branch to <see cref="Chain.ErrorLabel"/>. /// </remarks> public PhpTypeCode EmitEnsureStaticProperty(DProperty property, TypeRef typeRef, VariableName fieldName, bool ensureArray) { ILEmitter il = codeGenerator.IL; PhpField php_field = property as PhpField; if (php_field != null) { // HACK HACK EmitEnsureStaticPhpFieldDirect(php_field, ensureArray); EmitErrorCheck(ensureArray); return (ensureArray) ? PhpTypeCode.PhpArray : PhpTypeCode.DObject; } else return EmitEnsureStaticProperty(typeRef, fieldName, null, ensureArray); }
/// <summary> /// Emits IL instructions that ensure that a static field is of <see cref="PhpObject"/> or <see cref="PhpArray"/> /// type. Handles the case when field name is unknown at compile time (see <see cref="AST.IndirectStFldUse"/>). /// </summary> /// <param name="typeRef">The class name (identifier index).</param> /// <param name="propertyName">The property name.</param> /// <param name="propertyNameExpr">The expression that evaluates to property name.</param> /// <param name="ensureArray">Whether to ensure that static field is an array (or an object).</param> /// <remarks> /// Nothing is expected on the evaluation stack. A <see cref="PhpArray"/> or <see cref="DObject"/> is left on the /// evaluation stack. /// </remarks> public PhpTypeCode EmitEnsureStaticProperty(TypeRef typeRef, VariableName? propertyName, Expression propertyNameExpr, bool ensureArray) { Debug.Assert(propertyName != null ^ propertyNameExpr != null); ResolveTypeFlags flags = ResolveTypeFlags.UseAutoload | ResolveTypeFlags.ThrowErrors; // LOAD Operators.EnsureStaticFieldIs[Object|Array](<type desc>, <field name>, <type desc>, <context>) typeRef.EmitLoadTypeDesc(codeGenerator, flags); if (propertyNameExpr != null) codeGenerator.EmitBoxing(propertyNameExpr.Emit(codeGenerator)); else codeGenerator.IL.Emit(OpCodes.Ldstr, propertyName.Value.ToString()); codeGenerator.EmitLoadClassContext(); codeGenerator.EmitLoadScriptContext(); if (ensureArray) codeGenerator.IL.Emit(OpCodes.Call, Methods.Operators.EnsureStaticPropertyIsArray); else codeGenerator.IL.Emit(OpCodes.Call, Methods.Operators.EnsureStaticPropertyIsObject); EmitErrorCheck(ensureArray); return (ensureArray) ? PhpTypeCode.PhpArray : PhpTypeCode.DObject; }
public NamedActualParam(Position position, string name, Expression/*!*/ expression) : base(position) { this.name = new VariableName(name); this.expression = expression; }
internal DConstant ResolveClassConstantName(DType/*!*/ type, VariableName constantName, Position position, PhpType referringType, PhpRoutine referringRoutine, out bool checkVisibilityAtRuntime) { checkVisibilityAtRuntime = false; // we cannot resolve a class constant unless we know the inherited members: if (type.IsDefinite) { ClassConstant constant; GetMemberResult member_result = type.GetConstant(constantName, referringType, out constant); switch (member_result) { case GetMemberResult.OK: return constant; case GetMemberResult.NotFound: ErrorSink.Add(Errors.UnknownClassConstantAccessed, SourceUnit, position, type.FullName, constantName); return new UnknownClassConstant(type, constantName.Value); case GetMemberResult.BadVisibility: if (referringType == null && referringRoutine == null) { // visibility must be checked at run-time: checkVisibilityAtRuntime = true; return constant; } else { // definitive error: if (constant.IsPrivate) { ErrorSink.Add(Errors.PrivateConstantAccessed, SourceUnit, position, type.FullName, constantName.Value, referringType.FullName); } else { ErrorSink.Add(Errors.ProtectedConstantAccessed, SourceUnit, position, type.FullName, constantName.Value, referringType.FullName); } return new UnknownClassConstant(type, constantName.Value); } default: Debug.Fail(); throw null; } } else { // warning (if any) reported by the type resolver: return new UnknownClassConstant(type, constantName.Value); } }
/// <summary> /// Used by full-reflect. /// </summary> public ClrPropertyBase(DPropertyDesc/*!*/ propertyDesc, VariableName name) : base(propertyDesc, name) { }
/// <summary> /// Used by full-reflect. /// </summary> public ClrProperty(VariableName name, ClrTypeDesc/*!*/ declaringType, PhpMemberAttributes memberAttributes, PropertyInfo/*!*/ realProperty, bool hasGetter, bool hasSetter) : base(new DPropertyDesc(declaringType, memberAttributes), name) { Debug.Assert(realProperty != null); this.realProperty = realProperty; this.hasGetter = hasGetter; this.hasSetter = hasSetter; }
internal bool VariableIsAutoGlobal(VariableName name) { if (!currentVariablesTable.Contains(name)) { if (name.IsAutoGlobal) { return true; } Debug.Fail("DirectVarUse not in table and not auto-global!"); } return false; }
/// <summary> /// Used by full-reflect. /// </summary> public ClrEvent(VariableName name, ClrTypeDesc/*!*/ declaringType, PhpMemberAttributes memberAttributes, EventInfo/*!*/ realEvent, bool hasAddMethod, bool hasRemoveMethod) : base(new DPropertyDesc(declaringType, memberAttributes), name) { this.realEvent = realEvent; this.hasAddMethod = hasAddMethod; this.hasRemoveMethod = hasRemoveMethod; }
/// <summary> /// Emits an operation on auto-global variable with a specified name. /// </summary> /// <param name="name">The name of the auto-global variable.</param> /// <param name="opCode">The operation.</param> private void EmitAutoGlobalOperation(VariableName name, OpCode opCode) { FieldInfo fld = AutoGlobals.GetFieldForVariable(name); if (fld != null) il.Emit(opCode, fld); else Debug.Fail("Unsupported auto-global variable."); }
/// <summary> /// Used by compiler. /// </summary> public PhpField(VariableName name, DTypeDesc/*!*/ declaringType, PhpMemberAttributes memberAttributes, bool hasInitialValue, SourceUnit/*!*/ sourceUnit, Position position) : base(new DPhpFieldDesc(declaringType, memberAttributes), name) { this.hasInitialValue = hasInitialValue; this.position = position; this.sourceUnit = sourceUnit; this.builder = new PhpFieldBuilder(this); }
internal void EmitAutoGlobalLoadAddress(VariableName variableName) { EmitLoadAutoGlobals(); EmitAutoGlobalOperation(variableName, AutoGlobalLoadOpCode); il.Emit(OpCodes.Ldflda, Fields.PhpReference_Value); }
/// <summary> /// Used by full reflection for fields that are not implemented by their declaring type. /// <seealso cref="PhpPublicFieldAttribute"/> /// </summary> public PhpField(VariableName name, DPropertyDesc/*!*/ fieldDesc, DPropertyDesc/*!*/ implementingFieldDesc, bool hasInitialValue, PropertyInfo exportedProperty) : base(fieldDesc, name) { Debug.Assert(fieldDesc is DPhpFieldDesc); this.realField = implementingFieldDesc.PhpField.RealField; this.exportedProperty = exportedProperty; this.hasInitialValue = hasInitialValue; this.builder = null; this.implementor = implementingFieldDesc.DeclaringType.PhpType; this.upgradesVisibility = (IsPublic && implementingFieldDesc.IsProtected); }
internal void EmitAutoGlobalStorePrepare(VariableName variableName) { EmitLoadAutoGlobals(); EmitAutoGlobalOperation(variableName, AutoGlobalLoadOpCode); }
public ClassConstUse(Position position, TypeRef/*!*/typeRef, string/*!*/ name, Position namePosition) : base(position) { Debug.Assert(typeRef != null); Debug.Assert(!string.IsNullOrEmpty(name)); this.typeRef = typeRef; this.name = new VariableName(name); this.NamePosition = namePosition; }
internal void EmitAutoGlobalStoreRefPrepare(VariableName variableName) { EmitLoadAutoGlobals(); }
public virtual object hasProperty(ScriptContext/*!*/context, object argName) { if (this.typedesc == null) return false; var name = new VariableName(PHP.Core.Convert.ObjectToString(argName)); for (var type = this.typedesc; type != null; type = type.Base) if (type.Properties.ContainsKey(name)) return true; return false; }
internal void EmitAutoGlobalStoreRefAssign(VariableName variableName) { EmitAutoGlobalOperation(variableName, AutoGlobalStoreOpCode); }
public ConstantDecl(Position position, string/*!*/ name, Expression/*!*/ initializer) : base(position) { this.name = new VariableName(name); this.initializer = initializer; this.analyzed = false; }
/// <summary> /// Used by full reflection. /// </summary> public PhpVisibleProperty(VariableName name, DPropertyDesc/*!*/ fieldDesc, PropertyInfo/*!*/ propertyInfo) : base(fieldDesc, name) { Debug.Assert(fieldDesc is DPhpFieldDesc); Debug.Assert(propertyInfo != null); this.realProperty = propertyInfo; }