Esempio n. 1
0
 public SolidPrimitiveMsg(JSONNode msg)
 {
     _type = (primitive_type)UInt16.Parse(msg["type"]);
     foreach (JSONNode item in msg["dimensions"].AsArray)
     {
         _dimensions.Add(float.Parse(item));
     }
 }
            private bool IsSimpleForDeclaration(CS.Syntax.ForStatementSyntax node)
            {
#if false
                Declaration must be one of:
                var name = v1
                           primitive_type name = v1
#endif

                if (node.Declaration != null &&
                    node.Declaration.Variables.Count == 1 &&
                    node.Declaration.Variables[0].Initializer != null)
                {
                    if (node.Declaration.Type.IsVar || node.Declaration.Type.IsKind(CS.SyntaxKind.PredefinedType))
                    {
                        return(true);
                    }
                }

                return(false);
            }
            private bool IsSimpleForStatement(CS.Syntax.ForStatementSyntax node)
            {
                // Has to look like one of the following:
#if false
                for (Declaration; Condition; Incrementor)
                {
                    Declaration must be one of:
                    var name = v1
                               primitive_type name = v1

                                                     Condition must be one of:
                                                     name <v2
                                                           name <= v2
                                                           name> v2
                                                     name >= v2

                                                     Incrementor must be one of:
                                                     name++;
                }
                name--;
                name += v3;
                name -= v3;
#endif
                if (node.Declaration == null ||
                    node.Declaration.Variables.Count != 1)
                {
                    return(false);
                }

                string variableName = node.Declaration.Variables[0].Identifier.ValueText;

                return
                    (IsSimpleForDeclaration(node) &&
                     IsSimpleForCondition(node, variableName) &&
                     IsSimpleForIncrementor(node, variableName));
            }
Esempio n. 4
0
 public SolidPrimitiveMsg(primitive_type type, List <float> dimensions)
 {
     _type       = type;
     _dimensions = dimensions;
 }