コード例 #1
0
ファイル: JumpStmt.cs プロジェクト: dw4dev/Phalanger
		public GotoStmt(Text.Span span, string/*!*/labelName, Text.Span nameSpan)
			: base(span)
		{
            Debug.Assert(!string.IsNullOrEmpty(labelName));
			_labelName = new VariableName(labelName);
            _nameSpan = nameSpan;
		}
コード例 #2
0
        [NotNull] public static BaseModifyInPlace Create([NotNull] VariableName name, YololModifyOp op, bool pre)
        {
            switch (op)
            {
            case YololModifyOp.Increment: return(pre ? new PreIncrement(name) : (BaseModifyInPlace) new PostIncrement(name));

            case YololModifyOp.Decrement: return(pre ? new PreDecrement(name) : (BaseModifyInPlace) new PostIncrement(name));

            default: throw new ArgumentException($"Unknown YololModifyOp type `{op}`");
            }
        }
コード例 #3
0
        protected virtual int GetValuesHashCode()
        {
            int code = 23;

            if (IsVariable)
            {
                code = code * 31 + VariableName.GetHashCode();
                code = code * 31 + Agree.GetHashCode();
            }
            return(code);
        }
        IVariableReference BindVariable(VariableName varname, TextSpan span, Func <VariableName, TextSpan, LocalVariableReference> factory)
        {
            if (!_dict.TryGetValue(varname, out var value))
            {
                _dict[varname] = value = factory(varname, span);
            }

            //
            Debug.Assert(value != null);
            return(value);
        }
コード例 #5
0
ファイル: LocalsTable.cs プロジェクト: PeterDraex/peachpie
 BoundVariable CreateVariable(VariableName name, TextSpan span)
 {
     if (name.IsAutoGlobal)
     {
         return(new BoundSuperGlobalVariable(name));
     }
     else
     {
         return(new BoundLocal(new SourceLocalSymbol(_routine, name.Value, span)));
     }
 }
コード例 #6
0
ファイル: NameUtils.cs プロジェクト: PeterDraex/peachpie
        /// <summary>
        /// Tries to resolve global variable name from array item use. (eg. <c>$GLOBALS["varname"]</c>).
        /// </summary>
        public static bool TryGetGlobalVarName(ItemUse itemUse, out VariableName varname)
        {
            if (IsGlobalVar(itemUse) && itemUse.Index is StringLiteral)
            {
                varname = new VariableName(((StringLiteral)itemUse.Index).Value);
                return(true);
            }

            varname = default(VariableName);
            return(false);
        }
コード例 #7
0
        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;
        }
コード例 #8
0
 protected override VariableName Visit(VariableName var)
 {
     if (var.IsExternal)
     {
         return(base.Visit(var));
     }
     else
     {
         return(base.Visit(new VariableName(_remap[var.Name])));
     }
 }
コード例 #9
0
 public void Update()
 {
     if (exporter[0].pipline != null)
     {
         //export
         var _variableName = VariableName.ToString() + "_" + id.ToString();
         var _variableType = VariableData.VariableType.float1;
         var _var          = exporter[0].exportVariable = new VariableData(_variableName, _variableType);
         actionString = _var.VariableType2string(_variableType) + " " + _variableName + " = " + (inputFloat.text == string.Empty ? "0" : importer[0].importVariable.variableName + "*" + inputFloat.text).ToString() + "; \n";
     }
 }
コード例 #10
0
        public void Construct(CommonTree tree)
        {
            var syntaxExtendedId = tree.GetChild(0).CastTo <CommonTree>();

            VariableName = TreeHelper.GetExpression(this, Scope, syntaxExtendedId).CastTo <ExtendedId>();
            VariableName.Construct(syntaxExtendedId);

            var assignmentSyntax = tree.GetChild(1).CastTo <CommonTree>();

            AssignmentValue = TreeHelper.GetExpression(this, Scope, assignmentSyntax);
            AssignmentValue.Construct(assignmentSyntax);
        }
コード例 #11
0
ファイル: ScriptDom.cs プロジェクト: MarkMpn/Sql4Cds
        public void ToString(StringBuilder buf, int indent)
        {
            VariableName.ToString(buf);
            buf.Append(" ");
            DataType.ToString(buf, indent);

            if (Value != null)
            {
                buf.Append(" = ");
                Value.ToString(buf, indent);
            }
        }
コード例 #12
0
ファイル: FunctionDecl.cs プロジェクト: hansdude/Phalanger
		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;
		}
コード例 #13
0
ファイル: Node_UV.cs プロジェクト: Penguin77jp/Shader_Parts
 void Update()
 {
     if (exporter[0].pipline != null)
     {
         //export
         var _variableName = VariableName.ToString() + "_" + id.ToString();
         var _variableType = VariableData.VariableType.float2;
         var _var          = exporter[0].exportVariable = new VariableData(_variableName, _variableType);
         var importVar     = "i.uv";
         actionString = _var.VariableType2string(_variableType) + " " + _variableName + " = " + importVar + "; \n";
     }
 }
コード例 #14
0
        /// <summary>
        /// Gets or creates label data in the label collection.
        /// </summary>
        /// <param name="key">The name of the label.</param>
        /// <param name="position">label position</param>
        /// <returns>new Instance of LabelData</returns>
        public LabelData GetOrCreateLabelData(VariableName key, Position position)
        {
            LabelData data;

            if (!TryGetValue(key.Value, out data))
            {
                data = new LabelData(position);
                Add(key.Value, data);
            }

            return(data);
        }
コード例 #15
0
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hash = DefinitionVariableId.GetHashCode();
         // Suitable nullity checks etc, of course :)
         hash = hash * 17 + DefinitionId.GetHashCode();
         hash = (VariableName != null) ? hash * 17 + VariableName.GetHashCode() : hash;
         hash = hash * 17 + StoreType.GetHashCode();
         return(hash);
     }
 }
コード例 #16
0
ファイル: ForeachNode.cs プロジェクト: taekun/lens
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = (VariableName != null ? VariableName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IterableExpression != null ? IterableExpression.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (RangeStart != null ? RangeStart.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (RangeEnd != null ? RangeEnd.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Body != null ? Body.GetHashCode() : 0);
         return(hashCode);
     }
 }
コード例 #17
0
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hash = (Key != null) ? Key.GetHashCode() : 0;
         // Suitable nullity checks etc, of course :)
         hash = (VariableName != null) ? hash * 17 + VariableName.GetHashCode() : hash;
         hash = (DataType != null) ? hash * 17 + DataType.GetHashCode() : hash;
         hash = (ProcessItemKey != null) ? hash * 17 + ProcessItemKey.GetHashCode() : hash;
         return(hash);
     }
 }
コード例 #18
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("variableName");
     writer.WriteStringValue(VariableName.ToString());
     if (Selector != null)
     {
         writer.WritePropertyName("selector");
         writer.WriteStringValue(Selector);
     }
     writer.WriteEndObject();
 }
コード例 #19
0
ファイル: LocalsTable.cs プロジェクト: zhangwenquan/peachpie
        BoundVariable BindVariable(VariableName varname, TextSpan span, Func <VariableName, TextSpan, BoundVariable> factory)
        {
            BoundVariable value;

            if (!_dict.TryGetValue(varname, out value))
            {
                _dict[varname] = value = factory(varname, span);
            }

            //
            Debug.Assert(value != null);
            return(value);
        }
コード例 #20
0
ファイル: FunctionDecl.cs プロジェクト: jiahao42/weverca
        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;
            this.TypeHintPosition = Position.Invalid;
        }
コード例 #21
0
ファイル: LocalsTable.cs プロジェクト: PeterDraex/peachpie
        /// <summary>
        /// Gets local variable or create local if not yet.
        /// </summary>
        public BoundVariable BindVariable(VariableName varname, TextSpan span)
        {
            BoundVariable value;

            if (!_dict.TryGetValue(varname, out value))
            {
                _dict[varname] = value = CreateVariable(varname, span);
            }

            //
            Debug.Assert(value != null);
            return(value);
        }
コード例 #22
0
        internal void DefineBuilders()
        {
            if (realField == null)
            {
                TypeBuilder type_builder = this.DeclaringPhpType.RealTypeBuilder;

                // represent the class constant as a static initonly field
                FieldAttributes field_attrs = Enums.ToFieldAttributes(memberDesc.MemberAttributes);
                Type            field_type  = Types.Object[0];
                if (this.HasValue)
                {
                    var value = this.Value;
                    if (value == null || value is int || value is double || value is string || value is long || value is bool)
                    {
                        if (value != null)
                        {
                            field_type = value.GetType();
                        }

                        field_attrs |= FieldAttributes.Literal;
                    }
                    else
                    {
                        field_attrs |= FieldAttributes.InitOnly;
                    }
                }

                string name = FullName;
                if (IsExported)
                {
                    name += "#";
                }

                FieldBuilder fb = type_builder.DefineField(name, field_type, field_attrs);

                // [EditorBrowsable(Never)] for user convenience - not on silverlight
                // [ThreadStatic] for deferred constants
#if !SILVERLIGHT
                if (IsExported)
                {
                    fb.SetCustomAttribute(AttributeBuilders.EditorBrowsableNever);
                }
                if (!this.HasValue) // constant initialized for every request separatelly (same as static PHP field)
                {
                    fb.SetCustomAttribute(AttributeBuilders.ThreadStatic);
                }
#endif

                realField = fb;
            }
        }
コード例 #23
0
     /// <summary>
     /// Returns current point as a string along with variable names
     /// </summary>
     /// <param name="script">script from previous point</param>
     /// <returns>current point as a string along with variable names</returns>
     private String getThisPoint(ref String script)
     {
         VariableName[] varNames;
         if (var != null)
         {
             varNames = var.PossibleNames;
         }
         else
         {
             varNames = new VariableName[] { }
         };
         return(flow.printPoint(ref script, varNames));
     }
 }
コード例 #24
0
        /// <summary>
        /// Assigns the undefined value to the variable variableName.
        /// </summary>
        /// <param name='variableName'>
        /// The name of the variable which is assigned.
        /// </param>
        public void AssignUndefinedValue(VariableName variableName)
        {
            var undefList = new List <Value>();

            undefList.Add(valueFactory.UndefinedValue);
            if (!variableValues.ContainsKey(variableName))
            {
                variableValues.Add(variableName, undefList);
            }
            else
            {
                variableValues[variableName] = undefList;
            }
        }
コード例 #25
0
ファイル: CallEmitter.cs プロジェクト: m9ra/MEFEditor_v2.0
        /// <summary>
        /// Gets the variable.
        /// </summary>
        /// <param name="variable">The variable.</param>
        /// <param name="info">The information.</param>
        /// <returns>VariableName.</returns>
        private VariableName getVariable(string variable, InstanceInfo info)
        {
            var variableName = new VariableName(variable);

            InstanceInfo currentInfo;

            if (info != null && (!_staticVariableInfo.TryGetValue(variableName, out currentInfo) || object.Equals(currentInfo, null)))
            {
                //firstly determined variable info
                _staticVariableInfo[variableName] = info;
            }

            return(variableName);
        }
コード例 #26
0
ファイル: CallEmitter.cs プロジェクト: m9ra/MEFEditor_v2.0
        /// <summary>
        /// Get variable, which is not used yet in emitted code.
        /// </summary>
        /// <param name="description">Description of variable, used in name.</param>
        /// <returns>Name of variable.</returns>
        public override string GetTemporaryVariable(string description = "")
        {
            var          variable = "$tmp" + description;
            var          index    = _staticVariableInfo.Count;
            VariableName toRegister;

            while (_staticVariableInfo.ContainsKey(toRegister = new VariableName(variable + index)))
            {
                ++index;
            }

            _staticVariableInfo.Add(toRegister, default(InstanceInfo));
            return(variable + index);
        }
コード例 #27
0
        internal VariableKey(VariableKind kind, VariableName name, int contextStamp)
        {
            Kind = kind;
            Name = name;
            if (
                kind.HasFlag(VariableKind.Global) |
                kind.HasFlag(VariableKind.GlobalControl)
                )
            {
                contextStamp = 0;
            }

            ContextStamp = contextStamp;
        }
コード例 #28
0
ファイル: __ObsoleteLoop.cs プロジェクト: still-scene/t3
        private void Update(EvaluationContext context)
        {
            string variableName = VariableName.GetValue(context);
            float  end          = Count.GetValue(context);

            for (float i = 0f; i < end; i += 1.0f)
            {
                context.FloatVariables[variableName] = i;

                DirtyFlag.InvalidationRefFrame++;
                Command.Invalidate();
                Command.GetValue(context);
            }
        }
コード例 #29
0
        public virtual object hasConstant(ScriptContext /*!*/ context, object argName)
        {
            var name = new VariableName(PHP.Core.Convert.ObjectToString(argName));

            for (var type = this.typedesc; type != null; type = type.Base)
            {
                if (type.Constants.ContainsKey(name))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #30
0
        protected internal override void CheckSemantics(AstHelper astHelper)
        {
            VariableName.CheckSemantics(astHelper);
            VariableTypeName.CheckSemantics(astHelper);

            bool memberDeclared = astHelper.Errors.Check(new MemberWithSameNameAlreadyDefinedError(VariableName.Name, astHelper, Start));

            if (!memberDeclared)
            {
                Pointer = System.Linq.Expressions.Expression.Parameter(Type, VariableName.Name);

                astHelper.Variables.Add(VariableName.Name, Pointer);
            }
        }
コード例 #31
0
 public VariableName(VariableName variableName, string childName)
 {
     if (variableName.ChildName == null)
     {
         Name  = variableName.Name;
         Index = variableName.Index;
     }
     else
     {
         Name  = variableName;
         Index = default;
     }
     ChildName = childName;
 }
コード例 #32
0
        protected override BaseStatement Visit(If @if)
        {
            // Check that each branch contains just one statement...
            if (@if.FalseBranch.Statements.Count != 1)
            {
                return(@if);
            }
            if (@if.TrueBranch.Statements.Count != 1)
            {
                return(@if);
            }

            // ...and that those statements are goto statements
            if (!(@if.TrueBranch.Statements.Single() is Goto gotoTrue))
            {
                return(@if);
            }
            if (!(@if.FalseBranch.Statements.Single() is Goto gotoFalse))
            {
                return(@if);
            }

            // if A then goto B else goto C end
            var a = new Bracketed(new Or(@if.Condition, new ConstantNumber(0)));
            var b = new Bracketed(gotoTrue.Destination);
            var c = new Bracketed(gotoFalse.Destination);

            // goto A*(B-C)+C
            var g1 = new Goto(new Add(c, new Multiply(a, new Bracketed(new Subtract(b, c)))));

            // x=C goto A*(B-x)+x
            var x  = new VariableName(_names.Name());
            var g2 = new StatementList(
                new Assignment(x, c),
                new Goto(new Add(new Multiply(a, new Bracketed(new Subtract(b, new Variable(x)))), new Variable(x)))
                );

            // Return the shortest one (ignoring the length of the temporary variable name, assume that's optimised to 1 char)
            var xl = x.Name.Length * 2;

            if (g1.ToString().Length <= g2.ToString().Length - xl + 2)
            {
                return(g1);
            }
            else
            {
                return(g2);
            }
        }
コード例 #33
0
            public void Evaluate(GameTime gameTime, object Input, out bool IsCompleted, out List <object> Result)
            {
                string VariableNameLower = VariableName.ToLower();
                double Value             = (double)Input;

                if (!Info.Map.DicMapVariables.ContainsKey(VariableNameLower))
                {
                    if (SignOperator == Operators.SignOperators.Equal)
                    {
                        Info.Map.DicMapVariables.Add(VariableNameLower, Value);
                    }
                    else
                    {
                        throw new Exception(SignOperator.ToString() + " can't be used on " + VariableNameLower + " as this variable is unassigned.");
                    }
                }
                else
                {
                    switch (SignOperator)
                    {
                    case Operators.SignOperators.Equal:
                        Info.Map.DicMapVariables[VariableNameLower] = Value;
                        break;

                    case Operators.SignOperators.PlusEqual:
                        Info.Map.DicMapVariables[VariableNameLower] += Value;
                        break;

                    case Operators.SignOperators.MinusEqual:
                        Info.Map.DicMapVariables[VariableNameLower] -= Value;
                        break;

                    case Operators.SignOperators.MultiplicatedEqual:
                        Info.Map.DicMapVariables[VariableNameLower] *= Value;
                        break;

                    case Operators.SignOperators.DividedEqual:
                        Info.Map.DicMapVariables[VariableNameLower] /= Value;
                        break;

                    case Operators.SignOperators.ModuloEqual:
                        Info.Map.DicMapVariables[VariableNameLower] %= Value;
                        break;
                    }
                }

                Result      = new List <object>();
                IsCompleted = true;
            }
コード例 #34
0
		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;
		}
コード例 #35
0
ファイル: LocalsTable.cs プロジェクト: iolevel/peachpie
        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);
            }
        }
コード例 #36
0
        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;
        }
コード例 #37
0
ファイル: Properties.cs プロジェクト: tiaohai/Phalanger
		/// <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;
		}
コード例 #38
0
ファイル: Properties.cs プロジェクト: tiaohai/Phalanger
		/// <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);
		}
コード例 #39
0
ファイル: Properties.cs プロジェクト: tiaohai/Phalanger
		/// <summary>
		/// Used by subclasses.
		/// </summary>
		protected KnownProperty(DPropertyDesc/*!*/ propertyDesc, VariableName name)
			: base(propertyDesc)
		{
			this.name = name;

			// TODO
		}
コード例 #40
0
ファイル: Properties.cs プロジェクト: tiaohai/Phalanger
		/// <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;
		}
コード例 #41
0
ファイル: Properties.cs プロジェクト: tiaohai/Phalanger
		/// <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;
		}
コード例 #42
0
ファイル: CallSignature.cs プロジェクト: Ashod/Phalanger
		public NamedActualParam(Position position, string name, Expression/*!*/ expression)
			: base(position)
		{
			this.name = new VariableName(name);
			this.expression = expression;
		}
コード例 #43
0
ファイル: CodeGenerator.cs プロジェクト: dw4dev/Phalanger
		/// <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.");
		}
コード例 #44
0
ファイル: EditorModel.cs プロジェクト: hallgeirl/Hiage
 /// <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);
             }
         }
     }
 }
コード例 #45
0
ファイル: ConstantUse.cs プロジェクト: proff/Phalanger
        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;
        }
コード例 #46
0
ファイル: CodeGenerator.cs プロジェクト: dw4dev/Phalanger
		internal void EmitAutoGlobalStoreRefAssign(VariableName variableName)
		{
			EmitAutoGlobalOperation(variableName, AutoGlobalStoreOpCode);
		}
コード例 #47
0
ファイル: CodeGenerator.cs プロジェクト: dw4dev/Phalanger
		internal void EmitAutoGlobalStoreRefPrepare(VariableName variableName)
		{
			EmitLoadAutoGlobals();
		}
コード例 #48
0
ファイル: CodeGenerator.cs プロジェクト: dw4dev/Phalanger
		internal void EmitAutoGlobalStorePrepare(VariableName variableName)
		{
			EmitLoadAutoGlobals();
			EmitAutoGlobalOperation(variableName, AutoGlobalLoadOpCode);
		}
コード例 #49
0
ファイル: CodeGenerator.cs プロジェクト: dw4dev/Phalanger
		internal void EmitAutoGlobalLoadAddress(VariableName variableName)
		{
			EmitLoadAutoGlobals();
			EmitAutoGlobalOperation(variableName, AutoGlobalLoadOpCode);
			il.Emit(OpCodes.Ldflda, Fields.PhpReference_Value);
		}
コード例 #50
0
ファイル: Properties.cs プロジェクト: tiaohai/Phalanger
		/// <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);
		}
コード例 #51
0
ファイル: Chains.cs プロジェクト: dw4dev/Phalanger
		/// <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);
		}
コード例 #52
0
ファイル: CodeGenerator.cs プロジェクト: dw4dev/Phalanger
		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;
		}
コード例 #53
0
ファイル: Expression.cs プロジェクト: dw4dev/Phalanger
		public ConstantDecl(Text.Span span, string/*!*/ name, Expression/*!*/ initializer)
			: base(span)
		{
			this.name = new VariableName(name);
			this.initializer = initializer;
		}
コード例 #54
0
ファイル: Chains.cs プロジェクト: dw4dev/Phalanger
		/// <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;
		}
コード例 #55
0
ファイル: Properties.cs プロジェクト: tiaohai/Phalanger
        /// <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;
        }
コード例 #56
0
ファイル: Properties.cs プロジェクト: tiaohai/Phalanger
		/// <summary>
		/// Used by full-reflect.
		/// </summary>
		public ClrPropertyBase(DPropertyDesc/*!*/ propertyDesc, VariableName name)
			: base(propertyDesc, name)
		{
		}
コード例 #57
0
ファイル: ReflectionClass.cs プロジェクト: hansdude/Phalanger
        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;
        }
コード例 #58
0
ファイル: Properties.cs プロジェクト: tiaohai/Phalanger
		/// <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;
		}
コード例 #59
0
ファイル: Expression.cs プロジェクト: proff/Phalanger
		public ConstantDecl(Position position, string/*!*/ name, Expression/*!*/ initializer)
			: base(position)
		{
			this.name = new VariableName(name);
			this.initializer = initializer;
			this.analyzed = false;
		}
コード例 #60
0
ファイル: Analyzer.cs プロジェクト: Ashod/Phalanger
		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);
			}
		}