8000 sqlcipher/mkopcodeh.awk at master · orakle/sqlcipher · GitHub
[go: up one dir, main page]

Skip to content
{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"art","path":"art","contentType":"directory"},{"name":"contrib","path":"contrib","contentType":"directory"},{"name":"doc","path":"doc","contentType":"directory"},{"name":"ext","path":"ext","contentType":"directory"},{"name":"sqlcipher.xcodeproj","path":"sqlcipher.xcodeproj","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":"test","path":"test","contentType":"directory"},{"name":"tool","path":"tool","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"Makefile.arm-wince-mingw32ce-gcc","path":"Makefile.arm-wince-mingw32ce-gcc","contentType":"file"},{"name":"Makefile.in","path":"Makefile.in","contentType":"file"},{"name":"Makefile.linux-gcc","path":"Makefile.linux-gcc","contentType":"file"},{"name":"Makefile.msc","path":"Makefile.msc","contentType":"file"},{"name":"Makefile.vxworks","path":"Makefile.vxworks","contentType":"file"},{"name":"README","path":"README","contentType":"file"},{"name":"VERSION","path":"VERSION","contentType":"file"},{"name":"aclocal.m4","path":"aclocal.m4","contentType":"file"},{"name":"addopcodes.awk","path":"addopcodes.awk","contentType":"file"},{"name":"config.guess","path":"config.guess","contentType":"file"},{"name":"config.h.in","path":"config.h.in","contentType":"file"},{"name":"config.sub","path":"config.sub","contentType":"file"},{"name":"configure","path":"configure","contentType":"file"},{"name":"configure.ac","path":"configure.ac","contentType":"file"},{"name":"install-sh","path":"install-sh","contentType":"file"},{"name":"ltmain.sh","path":"ltmain.sh","contentType":"file"},{"name":"magic.txt","path":"magic.txt","contentType":"file"},{"name":"main.mk","path":"main.mk","contentType":"file"},{"name":"manifest","path":"manifest","contentType":"file"},{"name":"manifest.uuid","path":"manifest.uuid","contentType":"file"},{"name":"mkdll.sh","path":"mkdll.sh","contentType":"file"},{"name":"mkextu.sh","path":"mkextu.sh","contentType":"file"},{"name":"mkextw.sh","path":"mkextw.sh","contentType":"file"},{"name":"mkopcodec.awk","path":"mkopcodec.awk","contentType":"file"},{"name":"mkopcodeh.awk","path":"mkopcodeh.awk","contentType":"file"},{"name":"mkso.sh","path":"mkso.sh","contentType":"file"},{"name":"spec.template","path":"spec.template","contentType":"file"},{"name":"sqlcipher-1.1.8-testkey.db","path":"sqlcipher-1.1.8-testkey.db","contentType":"file"},{"name":"sqlcipher-2.0-be-testkey.db","path":"sqlcipher-2.0-be-testkey.db","contentType":"file"},{"name":"sqlcipher-2.0-beta-testkey.db","path":"sqlcipher-2.0-beta-testkey.db","contentType":"file"},{"name":"sqlcipher-2.0-le-testkey.db","path":"sqlcipher-2.0-le-testkey.db","contentType":"file"},{"name":"sqlcipher.1","path":"sqlcipher.1","contentType":"file"},{"name":"sqlcipher.pc.in","path":"sqlcipher.pc.in","contentType":"file"},{"name":"sqlite.pc.in","path":"sqlite.pc.in","contentType":"file"}],"totalCount":44}},"fileTreeProcessingTime":8.794898,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":13561316,"defaultBranch":"master","name":"sqlcipher","ownerLogin":"orakle","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2013-10-14T13:00:47.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/2844591?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1616156672.911432","canEdit":false,"refType":"branch","currentOid":"c61663d780a5eaae749b04ba9abd7f95d206ac88"},"path":"mkopcodeh.awk","currentUser":null,"blob":{"rawLines":["#!/usr/bin/awk -f","#","# Generate the file opcodes.h.","#","# This AWK script scans a concatenation of the parse.h output file from the","# parser and the vdbe.c source file in order to generate the opcodes numbers","# for all opcodes. ","#","# The lines of the vdbe.c that we are interested in are of the form:","#","# case OP_aaaa: /* same as TK_bbbbb */","#","# The TK_ comment is optional. If it is present, then the value assigned to","# the OP_ is the same as the TK_ value. If missing, the OP_ value is assigned","# a small integer that is different from every other OP_ value.","#","# We go to the trouble of making some OP_ values the same as TK_ values","# as an optimization. During parsing, things like expression operators","# are coded with TK_ values such as TK_ADD, TK_DIVIDE, and so forth. Later","# during code generation, we need to generate corresponding opcodes like","# OP_Add and OP_Divide. By making TK_ADD==OP_Add and TK_DIVIDE==OP_Divide,","# code to translate from one to the other is avoided. This makes the","# code generator run (infinitesimally) faster and more importantly it makes","# the library footprint smaller.","#","# This script also scans for lines of the form:","#","# case OP_aaaa: /* jump, in1, in2, in3, out2-prerelease, out3 */","#","# When such comments are found on an opcode, it means that certain","# properties apply to that opcode. Set corresponding flags using the","# OPFLG_INITIALIZER macro.","#","","","# Remember the TK_ values from the parse.h file","/^#define TK_/ {"," tk[$2] = 0+$3","}","","# Scan for \"case OP_aaaa:\" lines in the vdbe.c file","/^case OP_/ {"," name = $2"," sub(/:/,\"\",name)"," sub(\"\\r\",\"\",name)"," op[name] = -1"," jump[name] = 0"," out2_prerelease[name] = 0"," in1[name] = 0"," in2[name] = 0"," in3[name] = 0"," out2[name] = 0"," out3[name] = 0"," for(i=3; i\u003cNF; i++){"," if($i==\"same\" \u0026\u0026 $(i+1)==\"as\"){"," sym = $(i+2)"," sub(/,/,\"\",sym)"," op[name] = tk[sym]"," used[op[name]] = 1"," sameas[op[name]] = sym"," }"," x = $i"," sub(\",\",\"\",x)"," if(x==\"jump\"){"," jump[name] = 1"," }else if(x==\"out2-prerelease\"){"," out2_prerelease[name] = 1"," }else if(x==\"in1\"){"," in1[name] = 1"," }else if(x==\"in2\"){"," in2[name] = 1"," }else if(x==\"in3\"){"," in3[name] = 1"," }else if(x==\"out2\"){"," out2[name] = 1"," }else if(x==\"out3\"){"," out3[name] = 1"," }"," }"," order[n_op++] = name;","}","","# Assign numbers to all opcodes and output the result.","END {"," cnt = 0"," max = 0"," print \"/* Automatically generated. Do not edit */\""," print \"/* See the mkopcodeh.awk script for details */\""," op[\"OP_Noop\"] = -1;"," order[n_op++] = \"OP_Noop\";"," op[\"OP_Explain\"] = -1;"," order[n_op++] = \"OP_Explain\";"," for(i=0; i\u003cn_op; i++){"," name = order[i];"," if( op[name]\u003c0 ){"," cnt++"," while( used[cnt] ) cnt++"," op[name] = cnt"," }"," used[op[name]] = 1;"," if( op[name]\u003emax ) max = op[name]"," printf \"#define %-25s %15d\", name, op[name]"," if( sameas[op[name]] ) {"," printf \" /* same as %-12s*/\", sameas[op[name]]"," } "," printf \"\\n\"",""," }"," seenUnused = 0;"," for(i=1; i\u003cmax; i++){"," if( !used[i] ){"," if( !seenUnused ){"," printf \"\\n/* The following opcode values are never used */\\n\""," seenUnused = 1"," }"," printf \"#define %-25s %15d\\n\", sprintf( \"OP_NotUsed_%-3d\", i ), i"," }"," }",""," # Generate the bitvectors:"," #"," # bit 0: jump"," # bit 1: pushes a result onto stack"," # bit 2: output to p1. release p1 before opcode runs"," #"," for(i=0; i\u003c=max; i++) bv[i] = 0;"," for(i=0; i\u003cn_op; i++){"," name = order[i];"," x = op[name]"," a0 = a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0"," # a7 = a9 = a10 = a11 = a12 = a13 = a14 = a15 = 0"," if( jump[name] ) a0 = 1;"," if( out2_prerelease[name] ) a1 = 2;"," if( in1[name] ) a2 = 4;"," if( in2[name] ) a3 = 8;"," if( in3[name] ) a4 = 16;"," if( out2[name] ) a5 = 32;"," if( out3[name] ) a6 = 64;"," # bv[x] = a0+a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13+a14+a15;"," bv[x] = a0+a1+a2+a3+a4+a5+a6+a7;"," }"," print \"\\n\""," print \"/* Properties such as \\\"out2\\\" or \\\"jump\\\" that are specified in\""," print \"** comments following the \\\"case\\\" for each opcode in the vdbe.c\""," print \"** are encoded into bitvectors as follows:\""," print \"*/\""," print \"#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */\""," print \"#define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */\""," print \"#define OPFLG_IN1 0x0004 /* in1: P1 is an input */\""," print \"#define OPFLG_IN2 0x0008 /* in2: P2 is an input */\""," print \"#define OPFLG_IN3 0x0010 /* in3: P3 is an input */\""," print \"#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */\""," print \"#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */\""," print \"#define OPFLG_INITIALIZER {\\\\\""," for(i=0; i\u003c=max; i++){"," if( i%8==0 ) printf(\"/* %3d */\",i)"," printf \" 0x%02x,\", bv[i]"," if( i%8==7 ) printf(\"\\\\\\n\");"," }"," print \"}\"","}"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/orakle/sqlcipher/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"mkopcodeh.awk","displayUrl":"https://github.com/orakle/sqlcipher/blob/master/mkopcodeh.awk?raw=true","headerInfo":{"blobSize":"4.79 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"f6b90c1","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Forakle%2Fsqlcipher%2Fblob%2Fmaster%2Fmkopcodeh.awk","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"161","truncatedSloc":"155"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"Awk","languageID":28,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/orakle/sqlcipher/blob/master/mkopcodeh.awk","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/orakle/sqlcipher/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/orakle/sqlcipher/raw/refs/heads/master/mkopcodeh.awk","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":null},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/orakle/sqlcipher/branches":{"post":"nJxaHXMkjPfPiJayl-siVhnF6bmrYyodjA7ceR5adVxO-gYrxd1AzmnE26saGDZ5fjiOFEQYzpJ3XgsJFjoQTw"},"/repos/preferences":{"post":"LVQYLVQePR5DDQ0CuGYMbnu7vxzeQb0Uh4G8bU6W1WzBroQw1BRACJ2T_7Jzk2ZunaosPHCgbfsoqE2hdSK5sw"}}},"title":"sqlcipher/mkopcodeh.awk at master · orakle/sqlcipher","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1b17b3e7786a.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}
0