LEFT | RIGHT |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. | 3 # Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import json | 7 import json |
8 | 8 |
9 # This file contains the definitions for all the builtin in JSON format. | 9 # This file contains the definitions for all the builtin in JSON format. |
10 json_data = open('builtin_symbols.json') | 10 json_data = open('builtin_symbols.json') |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 TParameter param2 = {new TString(pname2), ptype2}; | 57 TParameter param2 = {new TString(pname2), ptype2}; |
58 f->addParameter(param2); | 58 f->addParameter(param2); |
59 TParameter param3 = {new TString(pname3), ptype3}; | 59 TParameter param3 = {new TString(pname3), ptype3}; |
60 f->addParameter(param3); | 60 f->addParameter(param3); |
61 t->insert(*f); | 61 t->insert(*f); |
62 } | 62 } |
63 | 63 |
64 """ | 64 """ |
65 output.write(registerfunc) | 65 output.write(registerfunc) |
66 | 66 |
67 # A function that parse the JSON representation of a list of builtin functions. | 67 # A function that parses the JSON representation of a list of builtin functions. |
68 def parseBuiltin(name): | 68 def parseBuiltin(name): |
69 » for func in builtin[name]: | 69 for func in builtin[name]: |
70 » » out = "" | 70 out = "" |
71 » » indent = " "; | 71 indent = " "; |
72 » » size = len(func['parameter']) | 72 size = len(func['parameter']) |
73 » » if 'condition' in func: | 73 if 'condition' in func: |
74 » » » out += indent + "if (" + func['condition'] + ") {\n" | 74 out += indent + "if (" + func['condition'] + ") {\n" |
75 » » » indent += indent; | 75 indent += indent; |
76 » » out += indent + "builtin" + str(size) + "(t, " | 76 out += indent + "builtin" + str(size) + "(t, " |
77 » » out += ttypeMap[func['return_type']] | 77 out += ttypeMap[func['return_type']] |
78 » » out += ", \"" + func['name'] + "\"" | 78 out += ", \"" + func['name'] + "\"" |
79 » » paramlist = func['parameter'] | 79 paramlist = func['parameter'] |
80 » » paramdef = ""; | 80 paramdef = ""; |
81 » » for param in paramlist: | 81 for param in paramlist: |
82 » » » paramdef += ", " | 82 paramdef += ", " |
83 » » » paramdef += ttypeMap[param['type']]· | 83 paramdef += ttypeMap[param['type']]· |
84 » » » paramdef += ", \"" + param['name'] + "\"" | 84 paramdef += ", \"" + param['name'] + "\"" |
85 » » out += paramdef + ");\n" | 85 out += paramdef + ");\n" |
86 » » if 'condition' in func: | 86 if 'condition' in func: |
87 » » » out += " }\n" | 87 out += " }\n" |
88 » » output.write(out) | 88 output.write(out) |
89 | 89 |
90 commonHeader = "void InsertBuiltInFunctionsCommon(const ShBuiltInResources& reso
urces, TSymbolTable * t) {\n" | 90 commonHeader = "void InsertBuiltInFunctionsCommon(const ShBuiltInResources& reso
urces, TSymbolTable* t) {\n" |
91 output.write(commonHeader) | 91 output.write(commonHeader) |
92 parseBuiltin("common") | 92 parseBuiltin("common") |
93 output.write("}\n\n") | 93 output.write("}\n\n") |
94 | 94 |
95 vertexHeader = "void InsertBuiltInFunctionsVertex(const ShBuiltInResources& reso
urces, TSymbolTable * t) {\n" | 95 vertexHeader = "void InsertBuiltInFunctionsVertex(const ShBuiltInResources& reso
urces, TSymbolTable* t) {\n" |
96 output.write(vertexHeader) | 96 output.write(vertexHeader) |
97 parseBuiltin("vertex") | 97 parseBuiltin("vertex") |
98 output.write("}\n\n") | 98 output.write("}\n\n") |
99 | 99 |
100 | |
101 json_data.close() | 100 json_data.close() |
102 output.close() | 101 output.close() |
LEFT | RIGHT |