/// <summary>
 /// Constructor for parameter symbol
 /// </summary>
 /// <param name="name"></param>
 /// <param name="symbolType"></param>
 /// <param name="parameter"></param>
 public ParameterSymbol(string name,SymbolType symbolType, Parameter parameter,
     VariableType variableType)
     : base(name,symbolType)
 {
     base.variableType = variableType;
     this.parameter = parameter;
 }
예제 #2
0
   public static Offset<VariableParameters> CreateVariableParameters(FlatBufferBuilder builder,
 VariableType type = (VariableType)0)
   {
       builder.StartObject(1);
       VariableParameters.AddType(builder, type);
       return VariableParameters.EndVariableParameters(builder);
   }
 /// <summary>
 /// Constuctor for function symbol
 /// </summary>
 /// <param name="name"></param>
 /// <param name="symbolType"></param>
 /// <param name="label"></param>
 /// <param name="paramList"></param>
 /// <param name="returnVar"></param>
 public FunctionSymbol(string name,SymbolType symbolType,string label,
     List<Parameter> paramList,VariableType returnVar)
     : base(name,symbolType,label,paramList)
 {
     this.returnVar = returnVar;
     this.variableType = returnVar;
 }
예제 #4
0
파일: GVar.cs 프로젝트: mcbodge/eidolon
        /**
         * The main Constructor.
         * An array of ID numbers is required, to ensure its own ID is unique.
         */
        public GVar(int[] idArray)
        {
            val = 0;
            floatVal = 0f;
            textVal = "";
            type = VariableType.Boolean;
            id = 0;
            link = VarLink.None;
            pmVar = "";
            popUps = null;
            updateLinkOnStart = false;
            backupVal = 0;
            backupFloatVal = 0f;

            // Update id based on array
            foreach (int _id in idArray)
            {
                if (id == _id)
                {
                    id ++;
                }
            }

            label = "Variable " + (id + 1).ToString ();
        }
예제 #5
0
 /// <summary>
 /// Main constructor
 /// </summary>
 /// <param name="superBlock">Super block</param>
 /// <param name="name">Method name</param>
 /// <param name="returnType">Method return type</param>
 /// <param name="parameters">Method parameters</param>
 public Method(Block superBlock, string name, VariableType returnType, Parameter[] parameters) : base(superBlock)
 {
     Name = name;
     ReturnType = returnType;
     Parameters = parameters;
     ReturnValue = null;
 }
예제 #6
0
 /// <summary>
 /// Constructor for a parameter
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="variableType"></param>
 public Parameter(string name,IOMode mode, VariableType variableType,int size)
 {
     this.mode = mode;
     this.variableType = variableType;
     this.name = name;
     this.size = size;
 }
예제 #7
0
 public Template(string[] iden, VariableType[] layout, bool casesens, VariableType infinitism)
 {
     _iden=iden;
     _layout=layout;
     _casesens=casesens;
     _infinitism=infinitism;
 }
예제 #8
0
        public LocationPreviewItem(VsProjectAnalyzer analyzer, FilePreviewItem parent, AnalysisLocation locationInfo, VariableType type) {
            _lineNo = locationInfo.Line;
            _columnNo = locationInfo.Column;            
            _parent = parent;
            var analysis = analyzer.GetAnalysisEntryFromPath(locationInfo.FilePath);
            _type = type;
            if (analysis != null) {
                string text = analysis.GetLine(locationInfo.Line);
                string trimmed = text.TrimStart(_whitespace);
                _text = trimmed;
                _span = new Span(_columnNo - (text.Length - trimmed.Length) - 1, parent.Engine.OriginalName.Length);
                if (String.Compare(_text, _span.Start, parent.Engine.OriginalName, 0, parent.Engine.OriginalName.Length) != 0) {
                    // we are renaming a name mangled name (or we have a bug where the names aren't lining up).
                    Debug.Assert(_text.Substring(_span.Start, _span.Length + 1 + parent.Engine.PrivatePrefix.Length) == "_" + parent.Engine.PrivatePrefix + parent.Engine.OriginalName);


                    if (parent.Engine.Request.Name.StartsWith("__")) {
                        // if we're renaming to a private prefix name then we just rename the non-prefixed portion
                        _span = new Span(_span.Start + 1 + parent.Engine.PrivatePrefix.Length, _span.Length);
                        _columnNo += 1 + parent.Engine.PrivatePrefix.Length;
                    } else {
                        // otherwise we renmae the prefixed and non-prefixed portion
                        _span = new Span(_span.Start, _span.Length + 1 + parent.Engine.PrivatePrefix.Length);
                    }
                }
            } else {
                _text = String.Empty;
            }
        }
예제 #9
0
        public ParameterDefinition(LittleBigCParser.FormalParameterContext context)
        {
            _context = context;

            var type = _context.variableType().simpleVariableType().GetText().ToString();

            _variableType = VariableDefinition.VariableTypes[type];
        }
예제 #10
0
 public void VariableConstructorTest1()
 {
     string name = string.Empty; // TODO: Initialize to an appropriate value
     VariableType type = new VariableType(); // TODO: Initialize to an appropriate value
     object value = null; // TODO: Initialize to an appropriate value
     Variable target = new Variable(name, type, value);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
예제 #11
0
        private static readonly ExpressionNode DefaultIntValueExpression = ExpressionNode.CreateConstantExpression(0); //the default value for an int is zero (0).

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new instance of the VariableDeclarationNode class.
        /// </summary>
        /// <param name="type">The type of the variable.</param>
        /// <param name="name">The name of the variable.</param>
        /// <param name="initialValue">A expression used to initialise the variable initially or null to use the default value.</param>
        public VariableDeclarationNode(VariableType type, string name, ExpressionNode initialValue)
        {
            Type = type;
            Name = name;

            initialValue = initialValue ?? DefaultIntValueExpression;
            InitialValueExpression = initialValue;
        }
 /// <summary>
 /// Constructor for Variable Symbol
 /// </summary>
 /// <param name="name"></param>
 /// <param name="size"></param>
 /// <param name="offset"></param>
 public VariableSymbol( string name, SymbolType symbolType, VariableType var,int size, 
     int offset)
     : base(name,symbolType)
 {
     this.size = size;
     this.offset = offset;
     this.variableType = var;
 }
예제 #13
0
 /// <summary>
 /// Creates the correct implementation of variable for the evaluation.
 /// </summary>
 /// <param name="variable">The oval definitions variable.</param>
 /// <returns></returns>
 public Evaluator CreateVariable(VariableType variable, oval_system_characteristics sytemCharacteristics, IEnumerable<VariableType> variablesOfDefinitions, oval_variables externalVariables)
 {
     if (variable is VariablesTypeVariableConstant_variable)
         return new ConstantVariableEvaluator((VariablesTypeVariableConstant_variable)variable);
     else if (variable is VariablesTypeVariableLocal_variable)
         return new LocalVariableEvaluator((VariablesTypeVariableLocal_variable)variable, sytemCharacteristics, variablesOfDefinitions, externalVariables);
     else if (variable is VariablesTypeVariableExternal_variable)
         return new ExternalVariableEvaluator((VariablesTypeVariableExternal_variable)variable, externalVariables);
        return null;
 }
예제 #14
0
 private void defineType(string value)
 {
     int i = 0;
     if(int.TryParse(value, out i))
         this.Type = VariableType.Number;
     else if(value.Equals("false") || value.Equals("true"))
         this.Type = VariableType.Boolean;
     else
         this.Type = VariableType.String;
 }
예제 #15
0
        /// <summary>
        /// Verifies Variable information in Burn_Manifest.xml.
        /// </summary>
        /// <param name="embededResourcesDirectoryPath">Output folder where all the embeded resources are.</param>
        /// <param name="variableName">Expected name of the variable.</param>
        /// <param name="variableValue">Expected value of the variable.</param>
        /// <param name="variableType">Expected Type of the variable.</param>
        public static void VerifyVariableInformation(string embededResourcesDirectoryPath, string variableName, string variableValue, VariableType variableType)
        {
            string expectedVariableTypeName = GetVariableTypeName(variableType);

            string burnManifestXPath = string.Format(@"//burn:Variable[@Id='{0}']", variableName);
            XmlNodeList burnManifestNodes = BundleTests.QueryBurnManifest(embededResourcesDirectoryPath, burnManifestXPath);
            Assert.True(1 == burnManifestNodes.Count, String.Format("No Variable with the name: '{0}' was found in Burn_Manifest.xml.", variableName));
            BundleTests.VerifyAttributeValue(burnManifestNodes[0], "Value", variableValue);
            BundleTests.VerifyAttributeValue(burnManifestNodes[0], "Type", expectedVariableTypeName);
        }
예제 #16
0
        public CompilerFunctionCall(Compiler compiler, CompilerFunction caller, Operand target, CallingConvention callingConvention, VariableType[] arguments, VariableType returnValue)
            : base(compiler)
        {
            Contract.Requires(arguments != null);

            _caller = caller;
            _target = target;

            _functionPrototype = new FunctionDeclaration(callingConvention, arguments, returnValue);
            if (arguments != null && arguments.Length > 0)
                _args = new Operand[arguments.Length];
        }
예제 #17
0
 public static Variable GetDefaultValue(VariableType v)
 {
     switch (v)
      {
     case VariableType.Boolean:
        return new Variable(bool.FalseString);
     case VariableType.Integer:
        return new Variable("0 ");
     default:
        throw new Exception("Invalid variable type.");
      }
 }
 public LocalVariableVariablesComponent(
     VariableType localVariable, 
     VariableComponentType variable, 
     IEnumerable<VariableType> variablesOfOvalDefinitions, 
     oval_system_characteristics systemCharacteristics,
     Modulo.Collect.OVAL.Variables.oval_variables externalVariables = null)
 {
     this.variablesOfDefinitions = variablesOfOvalDefinitions;
     this.variable = variable;
     this.systemCharacteristics = systemCharacteristics;
     this.localVariable = localVariable;
     this.variableEvaluator = new VariableEvaluator(variablesOfDefinitions, systemCharacteristics, externalVariables);
 }
예제 #19
0
        internal FunctionDeclaration(CallingConvention callingConvention, VariableType[] arguments, VariableType returnValue)
        {
            Contract.Requires(arguments != null);

            if (callingConvention == CallingConvention.Default)
                callingConvention = CallingConventionInfo.DefaultCallingConvention;

            _callingConvention = callingConvention;
            if (arguments.Length > 32)
                throw new ArgumentException();

            SetPrototype(arguments, returnValue);
        }
예제 #20
0
		public GVar ()
		{
			val = 0;
			floatVal = 0f;
			textVal = "";
			type = VariableType.Boolean;
			id = 0;
			link = VarLink.None;
			pmVar = "";
			popUps = null;
			updateLinkOnStart = false;

			label = "Variable " + (id + 1).ToString ();
		}
예제 #21
0
 /// <summary>
 /// Get the string value for a corresponding VariableType value.
 /// </summary>
 /// <param name="value">The variable type to convert</param>
 /// <returns>String representation</returns>
 public static string GetVariableTypeName(VariableType value)
 {
     switch (value)
     {
         case VariableType.Numeric:
             return "numeric";
         case VariableType.String:
             return "string";
         case VariableType.Version:
             return "version";
         default:
             throw new ArgumentOutOfRangeException("value", string.Format("Variable Type: '{0}' is not defined.", value.ToString()));
     };
 }
예제 #22
0
		public GVar (GVar assetVar)
		{
			// Duplicates Asset to Runtime instance
			// (Do it the long way to ensure no connections remain to the asset file)
			
			val = assetVar.val;
			floatVal = assetVar.floatVal;
			textVal = assetVar.textVal;
			type = assetVar.type;
			id = assetVar.id;
			label = assetVar.label;
			link = assetVar.link;
			pmVar = assetVar.pmVar;
			popUps = assetVar.popUps;
			updateLinkOnStart = assetVar.updateLinkOnStart;
		}
예제 #23
0
        public Variable(string name, VariableType type)
        {
            AmountOfVariables++;
            this.Name = name.Trim();

            this.IsUsedAsControl = false;
            this.IsInputed = false;
            this.IsUsedForComputing = false;
            if (type == VariableType.Field)
                this.IsModefied = false;
            else 
                this.SetModefied();

            if (!AllVariableNames.Contains(name))
                AllVariableNames.Add(name);
        }
    public static bool Contains(this VariableType[] target, VariableType vType)
    {
        if (target == null)
        {
            return false;
        }

        for (int index = 0; index < target.Length; index++)
        {
            if ( target[index] == vType)
            {
                return true;
            }
        }

        return false;
    }
        VariablesChapinData(string name, VariableType type)
        {
            this.Name = name;

            IsControlVariable = false;
            IsInputed = false;

            if (type == VariableType.Field)
            {
                IsModefied = false;
                IsUsed = true;
            }
            else
            {
                IsModefied = true;
                IsUsed = true;
            }
        }
예제 #26
0
        public CompilerVar(CompilerFunction scope, int id, VariableType type, int size, string name)
        {
            if (scope == null)
                throw new ArgumentNullException("scope");
            Contract.EndContractBlock();

            _scope = scope;
            _id = id;
            _type = type;
            _size = size;
            _name = name;

            HomeRegisterIndex = RegIndex.Invalid;
            PreferredRegisterMask = RegisterMask.All;
            RegisterIndex = RegIndex.Invalid;
            WorkOffset = Operand.InvalidValue;
            Priority = 10;
            State = VariableState.Unused;
        }
예제 #27
0
        private static void PrintBlock(CodeGenContext context, AstBlock block)
        {
            AstBlockVisitor visitor = new AstBlockVisitor(block);

            visitor.BlockEntered += (sender, e) =>
            {
                switch (e.Block.Type)
                {
                case AstBlockType.DoWhile:
                    context.AppendLine("do");
                    break;

                case AstBlockType.Else:
                    context.AppendLine("else");
                    break;

                case AstBlockType.ElseIf:
                    context.AppendLine($"else if ({GetCondExpr(context, e.Block.Condition)})");
                    break;

                case AstBlockType.If:
                    context.AppendLine($"if ({GetCondExpr(context, e.Block.Condition)})");
                    break;

                default: throw new InvalidOperationException($"Found unexpected block type \"{e.Block.Type}\".");
                }

                context.EnterScope();
            };

            visitor.BlockLeft += (sender, e) =>
            {
                context.LeaveScope();

                if (e.Block.Type == AstBlockType.DoWhile)
                {
                    context.AppendLine($"while ({GetCondExpr(context, e.Block.Condition)});");
                }
            };

            foreach (IAstNode node in visitor.Visit())
            {
                if (node is AstOperation operation)
                {
                    context.AppendLine(InstGen.GetExpression(context, operation) + ";");
                }
                else if (node is AstAssignment assignment)
                {
                    VariableType srcType = OperandManager.GetNodeDestType(context, assignment.Source);
                    VariableType dstType = OperandManager.GetNodeDestType(context, assignment.Destination);

                    string dest;

                    if (assignment.Destination is AstOperand operand && operand.Type == OperandType.Attribute)
                    {
                        dest = OperandManager.GetOutAttributeName(operand, context.Config);
                    }
                    else
                    {
                        dest = InstGen.GetExpression(context, assignment.Destination);
                    }

                    string src = ReinterpretCast(context, assignment.Source, srcType, dstType);

                    context.AppendLine(dest + " = " + src + ";");
                }
 public override bool SupportsType(VariableType type)
 {
     return(type == VariableType.Decal || type == VariableType.Material || type == VariableType.Sprite);
 }
예제 #29
0
 public bool VisitNode(VariableType node)
 {
     Append(node.Name);
     return(true);
 }
예제 #30
0
 public VariableLocation(int startLine, int startCol, VariableType type)
 {
     StartLine = startLine;
     StartCol  = startCol;
     Type      = type;
 }
예제 #31
0
 public VariableLocation(int startLine, int startCol, VariableType type, string filePath)
     : this(startLine, startCol, type)
 {
     FilePath       = filePath;
     _validFilePath = true;
 }
예제 #32
0
 public DateStamp(string name, string value, VariableType valueType, string parseFormat, string displayFormat)
     : base(name, value, valueType, parseFormat, displayFormat)
 {
     Parse(value);
     Value = _dateStamp;
 }
예제 #33
0
 public Reference(T target, VariableType type)
 {
     Type   = type;
     Target = target;
 }
        protected void HandleAssignationOperator(Node node, VariableType type = VariableType.Void)
        {
            var       targetType     = VariableType.Error;
            IVariable targetVariable = new Variable("", VariableType.Error, -1);
            Variable  sourceVariable;

            if (node.Left.Type == NodeType.Type || type != VariableType.Void && node.Left.Type == NodeType.Indexer)
            {
                if (type == VariableType.Void)
                {
                    targetType = HandleType(node.Left, out targetVariable);
                }
                else
                {
                    targetType     = type;
                    targetVariable = GetVariableByName(node.Left.Left);
                }

                if (targetVariable is Array array)
                {
                    if (node.Right.Value != "{}")
                    {
                        AddError(node.Right.StartPosition, Glossary.InvalidInitializer());
                        return;
                    }

                    var currentIndex = -1;
                    var currentNode  = node.Right.Left;
                    while (currentNode?.Value == ",")
                    {
                        if (currentNode.Left != null)
                        {
                            currentIndex++;
                            var elem = array.GetAtIndex(currentIndex);
                            sourceVariable = GetValue(currentNode.Left);
                            if (sourceVariable == null)
                            {
                                return;
                            }
                            if (!TryCast(sourceVariable.Type, targetType))
                            {
                                AddError(currentNode.Left.StartPosition, Glossary.CastError(sourceVariable.Type, targetType));
                                return;
                            }
                            if (sourceVariable is Variable elemVariable && sourceVariable.IsTemp)
                            {
                                Mov(elem, elemVariable);
                            }
                        }
                        currentNode = currentNode.Right;
                    }

                    if (currentNode != null)
                    {
                        currentIndex++;
                        if (currentIndex >= array.Length)
                        {
                            return;
                        }
                        var elem = array.GetAtIndex(currentIndex);
                        sourceVariable = GetValue(currentNode);
                        if (sourceVariable == null)
                        {
                            return;
                        }
                        if (!TryCast(sourceVariable.Type, targetType))
                        {
                            AddError(currentNode.StartPosition, Glossary.CastError(sourceVariable.Type, targetType));
                            return;
                        }
                        if (sourceVariable is Variable elemVariable && sourceVariable.IsTemp)
                        {
                            Mov(elem, elemVariable);
                            return;
                        }
                        AddError(currentNode.StartPosition, Glossary.InvalidInitializer());
                        return;
                    }
                }
                else
                {
                    _lastVariable = (Variable)targetVariable;
                }
            }

            else if (node.Left.Type == NodeType.Name || type != VariableType.Void)
            {
                targetVariable = GetVariableByName(node.Left);
                if (targetVariable is Pointer pointer)
                {
                    targetType = VariableType.Pointer;
                }
                else
                {
                    targetType = targetVariable?.Type ?? VariableType.Error;
                }
            }

            else if (node.Left.Type == NodeType.Indexer)
            {
                if (!(GetVariableByName(node.Left.Left) is Array array))
                {
                    AddError(node.StartPosition, Glossary.NotArray(node.Left.Value));
                    return;
                }
                var arrayMember = GetArrayMember(node.Left);
                targetType = array.Type;
                if (arrayMember != null)
                {
                    targetVariable = arrayMember;
                }
            }

            else if (node.Left.Type == NodeType.Pointer)
            {
                if (node.Value == "*")
                {
                    if (!(GetVariableByName(node.Left) is Pointer pointer))
                    {
                        AddError(node.StartPosition, Glossary.NotPointer(node.Left.Value));
                        return;
                    }

                    targetType = pointer.Type;
                }
            }

            sourceVariable = GetValue(node.Right);
            if (sourceVariable == null || targetVariable == null)
            {
                return;
            }
            if (!TryCast(sourceVariable.Type, targetVariable.Type))
            {
                AddError(node.StartPosition, Glossary.CastError(sourceVariable.Type, targetType));
                return;
            }

            _lastVariable = (Variable)targetVariable;
//			if (targetVariable.Type > VariableType.LongLong)
//			{
//				if (sourceVariable.IsFloat)
//				{
//					AddCode($"fld float_const{sourceVariable.Reg}");
//				}
//				else
//				{
//					AddCode($"fild {sourceVariable.Name}");
//				}
//				AddCode($"fstp {targetVariable.Name}");
//				return;
//			}
            Mov((Variable)targetVariable, sourceVariable);
        }
예제 #35
0
 public DateStamp(string name, DateTime value, VariableType valueType, string parseFormat, string displayFormat)
     : base(name, value, valueType, parseFormat, displayFormat)
 {
     _dateStamp = value;
 }
예제 #36
0
 public virtual VariableAction CreateVariableAction(VariableType type)
 {
     VariableAction action = new VariableAction(type);
     action.Compile(this);
     if (action.VarKey != InvalidQueryKey)
     {
         return action;
     }
     else
     {
         return null;
     }
 }
예제 #37
0
파일: Variable.cs 프로젝트: pczy/Pub.Class
 Variable(VariableType type, int index) {
     this.VarType = type;
     this.Index = index;
 }
예제 #38
0
 /// <summary>
 /// Set the type of <see cref="Variable"/> the current instance of <see cref="DeclareVariableQuery"/>
 /// is building as <see cref="VariableType.Numeric"/>.
 /// </summary>
 /// <returns></returns>
 public IBuild <Variable> Numeric()
 {
     _type = VariableType.Numeric;
     return(this);
 }
예제 #39
0
 public BuiltInAttribute(string name, VariableType type)
 {
     Name = name;
     Type = type;
 }
예제 #40
0
 public static extern bool Transcode(PixelFormat ptFormat, VariableType eChannelType, ColourSpace eColourspace, CompressorQuality eQuality = CompressorQuality.PVRTCNormal, bool bDoDither = false);
예제 #41
0
 public override bool SupportsType(VariableType type)
 {
     return(type == VariableType.Color255);
 }
예제 #42
0
        public static void CreateTexture <T>(T[] data, uint u32Width, uint u32Height, uint u32Depth, PixelFormat ptFormat, bool preMultiplied, VariableType eChannelType, ColourSpace eColourspace)
        {
            var gcHandle = GCHandle.Alloc(data, GCHandleType.Pinned);

            CreateTexture(gcHandle.AddrOfPinnedObject(), u32Width, u32Height, u32Depth, ptFormat, preMultiplied, eChannelType, eColourspace);
            gcHandle.Free();
        }
예제 #43
0
파일: Variable.cs 프로젝트: paulem/resxul
 public Variable(VariableType type, string name, string description)
 {
     Type        = type;
     Name        = name;
     Description = description;
 }
 public TypeValue(VariableType type, string value)
 {
     Type  = type;
     Value = value;
 }
예제 #45
0
 public AnalysisVariable(VariableType type, LocationInfo location)
 {
     _loc  = location;
     _type = type;
 }
예제 #46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkFlowVariable"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="value">The value.</param>
 /// <param name="variableType">Type of the variable.</param>
 public WorkFlowVariable(string name, string value, VariableType variableType)
 {
     Name  = name;
     Value = value;
     Type  = variableType;
 }
예제 #47
0
파일: Text.cs 프로젝트: mcskik/Utilities
 public Text(string name, string value, VariableType valueType, string parseFormat, string displayFormat)
     : base(name, value, valueType, parseFormat, displayFormat)
 {
     _text = value;
 }
 /// <summary>
 /// Returns the Variable type enumeration value.
 /// </summary>
 /// <param name="typeCombination">Variable Type enum combination.</param>
 /// <returns>True/False on variable type test.</returns>
 public bool IsVarType(VariableType typeCombination)
 {
     return(VariableBase.IsVarType(this.VarType, typeCombination));
 }
예제 #49
0
 /// <summary>
 /// Creates a new collection of variables.
 /// </summary>
 /// <param name="solver">The solver the variable collection belongs to.</param>
 /// <param name="variableType">The type of the variables in the collection.</param>
 /// <param name="lowerBound">The default lower bound when adding a variable on-the-fly.</param>
 /// <param name="upperBound">The default upper bound when adding a variable on-the-fly.</param>
 public VariableCollection(LinearModel solver, VariableType variableType, double lowerBound, double upperBound) : base(solver, variableType, lowerBound, upperBound)
 {
 }
예제 #50
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Variable"/> class.
 /// </summary>
 /// <param name="state">The state where the script variable will be used.</param>
 /// <param name="variableType">Type of the variable.</param>
 public Variable(State state, VariableType variableType)
     : base(state)
 {
     _value = VarFactory.Create(variableType);
 }
예제 #51
0
        public LocationPreviewItem(VsProjectAnalyzer analyzer, FilePreviewItem parent, AnalysisLocation locationInfo, VariableType type)
        {
            _lineNo   = locationInfo.Line;
            _columnNo = locationInfo.Column;
            _parent   = parent;
            var analysis = analyzer.GetAnalysisEntryFromPath(locationInfo.FilePath);

            _type = type;
            if (analysis != null)
            {
                string text    = analysis.GetLine(locationInfo.Line);
                string trimmed = text.TrimStart(_whitespace);
                _text = trimmed;
                _span = new Span(_columnNo - (text.Length - trimmed.Length) - 1, parent.Engine.OriginalName.Length);
                if (String.Compare(_text, _span.Start, parent.Engine.OriginalName, 0, parent.Engine.OriginalName.Length) != 0)
                {
                    // we are renaming a name mangled name (or we have a bug where the names aren't lining up).
                    Debug.Assert(_text.Substring(_span.Start, _span.Length + 1 + parent.Engine.PrivatePrefix.Length) == "_" + parent.Engine.PrivatePrefix + parent.Engine.OriginalName);


                    if (parent.Engine.Request.Name.StartsWith("__"))
                    {
                        // if we're renaming to a private prefix name then we just rename the non-prefixed portion
                        _span      = new Span(_span.Start + 1 + parent.Engine.PrivatePrefix.Length, _span.Length);
                        _columnNo += 1 + parent.Engine.PrivatePrefix.Length;
                    }
                    else
                    {
                        // otherwise we renmae the prefixed and non-prefixed portion
                        _span = new Span(_span.Start, _span.Length + 1 + parent.Engine.PrivatePrefix.Length);
                    }
                }
            }
            else
            {
                _text = String.Empty;
            }
        }
예제 #52
0
 public static extern void CreateTexture(IntPtr data, uint u32Width, uint u32Height, uint u32Depth, PixelFormat ptFormat, bool preMultiplied, VariableType eChannelType, ColourSpace eColourspace);
예제 #53
0
        private static void AddOperation(StructuredProgramContext context, LinkedListNode <INode> opNode)
        {
            Operation operation = (Operation)opNode.Value;

            Instruction inst = operation.Inst;

            bool isCall = inst == Instruction.Call;

            int sourcesCount = operation.SourcesCount;

            List <Operand> callOutOperands = new List <Operand>();

            if (isCall)
            {
                LinkedListNode <INode> scan = opNode.Next;

                while (scan != null && scan.Value is Operation nextOp && nextOp.Inst == Instruction.CallOutArgument)
                {
                    callOutOperands.Add(nextOp.Dest);
                    scan = scan.Next;
                }

                sourcesCount += callOutOperands.Count;
            }

            IAstNode[] sources = new IAstNode[sourcesCount];

            for (int index = 0; index < operation.SourcesCount; index++)
            {
                sources[index] = context.GetOperandUse(operation.GetSource(index));
            }

            if (isCall)
            {
                for (int index = 0; index < callOutOperands.Count; index++)
                {
                    sources[operation.SourcesCount + index] = context.GetOperandDef(callOutOperands[index]);
                }

                callOutOperands.Clear();
            }

            AstTextureOperation GetAstTextureOperation(TextureOperation texOp)
            {
                return(new AstTextureOperation(
                           inst,
                           texOp.Type,
                           texOp.Format,
                           texOp.Flags,
                           texOp.Handle,
                           4, // TODO: Non-hardcoded array size.
                           texOp.Index,
                           sources));
            }

            if (operation.Dest != null)
            {
                AstOperand dest = context.GetOperandDef(operation.Dest);

                if (inst == Instruction.LoadConstant)
                {
                    Operand slot = operation.GetSource(0);

                    if (slot.Type == OperandType.Constant)
                    {
                        context.Info.CBuffers.Add(slot.Value);
                    }
                    else
                    {
                        // If the value is not constant, then we don't know
                        // how many constant buffers are used, so we assume
                        // all of them are used.
                        int cbCount = 32 - BitOperations.LeadingZeroCount(context.Config.GpuAccessor.QueryConstantBufferUse());

                        for (int index = 0; index < cbCount; index++)
                        {
                            context.Info.CBuffers.Add(index);
                        }

                        context.Info.UsesCbIndexing = true;
                    }
                }
                else if (UsesStorage(inst))
                {
                    AddSBufferUse(context.Info.SBuffers, operation);
                }

                // If all the sources are bool, it's better to use short-circuiting
                // logical operations, rather than forcing a cast to int and doing
                // a bitwise operation with the value, as it is likely to be used as
                // a bool in the end.
                if (IsBitwiseInst(inst) && AreAllSourceTypesEqual(sources, VariableType.Bool))
                {
                    inst = GetLogicalFromBitwiseInst(inst);
                }

                bool isCondSel = inst == Instruction.ConditionalSelect;
                bool isCopy    = inst == Instruction.Copy;

                if (isCondSel || isCopy)
                {
                    VariableType type = GetVarTypeFromUses(operation.Dest);

                    if (isCondSel && type == VariableType.F32)
                    {
                        inst |= Instruction.FP32;
                    }

                    dest.VarType = type;
                }
                else
                {
                    dest.VarType = InstructionInfo.GetDestVarType(inst);
                }

                IAstNode source;

                if (operation is TextureOperation texOp)
                {
                    if (texOp.Inst == Instruction.ImageLoad || texOp.Inst == Instruction.ImageStore)
                    {
                        dest.VarType = texOp.Format.GetComponentType();
                    }

                    AstTextureOperation astTexOp = GetAstTextureOperation(texOp);

                    if (texOp.Inst == Instruction.ImageLoad)
                    {
                        context.Info.Images.Add(astTexOp);
                    }
                    else
                    {
                        context.Info.Samplers.Add(astTexOp);
                    }

                    source = astTexOp;
                }
                else if (!isCopy)
                {
                    source = new AstOperation(inst, operation.Index, sources, operation.SourcesCount);
                }
                else
                {
                    source = sources[0];
                }

                context.AddNode(new AstAssignment(dest, source));
            }
            else if (operation.Inst == Instruction.Comment)
            {
                context.AddNode(new AstComment(((CommentNode)operation).Comment));
            }
            else if (operation is TextureOperation texOp)
            {
                AstTextureOperation astTexOp = GetAstTextureOperation(texOp);

                context.Info.Images.Add(astTexOp);

                context.AddNode(astTexOp);
            }
            else
            {
                if (UsesStorage(inst))
                {
                    AddSBufferUse(context.Info.SBuffers, operation);
                }

                context.AddNode(new AstOperation(inst, operation.Index, sources, operation.SourcesCount));
            }

            // Those instructions needs to be emulated by using helper functions,
            // because they are NVIDIA specific. Those flags helps the backend to
            // decide which helper functions are needed on the final generated code.
            switch (operation.Inst)
            {
            case Instruction.MultiplyHighS32:
                context.Info.HelperFunctionsMask |= HelperFunctionsMask.MultiplyHighS32;
                break;

            case Instruction.MultiplyHighU32:
                context.Info.HelperFunctionsMask |= HelperFunctionsMask.MultiplyHighU32;
                break;

            case Instruction.Shuffle:
                context.Info.HelperFunctionsMask |= HelperFunctionsMask.Shuffle;
                break;

            case Instruction.ShuffleDown:
                context.Info.HelperFunctionsMask |= HelperFunctionsMask.ShuffleDown;
                break;

            case Instruction.ShuffleUp:
                context.Info.HelperFunctionsMask |= HelperFunctionsMask.ShuffleUp;
                break;

            case Instruction.ShuffleXor:
                context.Info.HelperFunctionsMask |= HelperFunctionsMask.ShuffleXor;
                break;

            case Instruction.SwizzleAdd:
                context.Info.HelperFunctionsMask |= HelperFunctionsMask.SwizzleAdd;
                break;
            }
        }
예제 #54
0
        public override string ToString()
        {
            var indentString = "// " + new string(Enumerable.Repeat(' ', _indent).ToArray());
            var sb           = new StringBuilder();

            if (_isFirst)
            {
                sb.AppendLine(indentString);
            }
            switch (VariableClass)
            {
            case ShaderVariableClass.InterfacePointer:
            case ShaderVariableClass.MatrixColumns:
            case ShaderVariableClass.MatrixRows:
            {
                sb.Append(indentString);
                if (!string.IsNullOrEmpty(BaseTypeName))                         // BaseTypeName is only populated in SM 5.0
                {
                    sb.Append(string.Format("{0}{1}", VariableClass.GetDescription(), BaseTypeName));
                }
                else
                {
                    sb.Append(VariableClass.GetDescription());
                    sb.Append(VariableType.GetDescription());
                    if (Columns > 1)
                    {
                        sb.Append(Columns);
                        if (Rows > 1)
                        {
                            sb.Append("x" + Rows);
                        }
                    }
                }
                break;
            }

            case ShaderVariableClass.Vector:
            {
                sb.Append(indentString + VariableType.GetDescription());
                sb.Append(Columns);
                break;
            }

            case ShaderVariableClass.Struct:
            {
                if (!_isFirst)
                {
                    sb.AppendLine(indentString);
                }
                sb.AppendLine(indentString + "struct " + BaseTypeName);
                sb.AppendLine(indentString + "{");
                foreach (var member in Members)
                {
                    sb.AppendLine(member.ToString());
                }
                sb.AppendLine("//");
                sb.Append(indentString + "}");
                break;
            }

            case ShaderVariableClass.Scalar:
            {
                sb.Append(indentString + VariableType.GetDescription());
                break;
            }

            default:
                throw new InvalidOperationException(string.Format("Variable class '{0}' is not currently supported.", VariableClass));
            }
            return(sb.ToString());
        }
예제 #55
0
 /// <summary>
 /// Set the type of <see cref="Variable"/> the current instance of <see cref="DeclareVariableQuery"/>
 /// is building as <see cref="VariableType.String"/>.
 /// </summary>
 /// <returns></returns>
 public IBuild <Variable> String()
 {
     _type = VariableType.String;
     return(this);
 }
예제 #56
0
 public ControlledVariable(VariableType variableType)
 {
     _variableType = variableType;
 }
예제 #57
0
	public HamTimelineVariable AddVariable(string name, VariableType type)
	{
		int id = this.IDCount++;
		HamTimelineVariable v = new HamTimelineVariable(id, type, name);
		this.Variables[id] = v;
		return v;
	}
예제 #58
0
 /// <summary>
 /// Set the type of <see cref="Variable"/> the current instance of <see cref="DeclareVariableQuery"/>
 /// is building as <see cref="VariableType.Date"/>.
 /// </summary>
 /// <returns></returns>
 public IBuild <Variable> Date()
 {
     _type = VariableType.Date;
     return(this);
 }
예제 #59
0
 public Variable(ElementType type, VariableType vtype, int index)
     : this(type)
 {
     Index = index;
     VarType = vtype;
 }
예제 #60
0
 internal string getFsmVariableType(VariableType _type)
 {
     return(_type.ToString());
 }