Example #1
0
Function Function_getFunction(PG_FUNCTION_ARGS)
{
	Oid funcOid = fcinfo->flinfo->fn_oid;
	Function func = (Function)HashMap_getByOid(s_funcMap, funcOid);
	if(func == 0)
	{
		func = Function_create(fcinfo);
		HashMap_putByOid(s_funcMap, funcOid, func);
	}
	return func;
}
Example #2
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  ParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  **
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
  ** without this code, their parser segfaults.  I'm not sure what there
  ** parser is doing to make this happen.  This is the second bug report
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
  ** that it has not been previously stressed...  (SQLite ticket #2172)
  */
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  yygotominor = yyzerominor;


  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0: /* module ::= statements */
      case 1: /* statements ::= statement */
      case 2: /* statements ::= statements statement */
      case 34: /* element ::= operation */
      case 35: /* element ::= directive */
      case 38: /* element ::= */
      case 39: /* statements ::= statements error statement */
#line 56 "grammar.y"
{
}
#line 747 "grammar.c"
        break;
      case 3: /* statement ::= directive EOL */
      case 4: /* statement ::= constant EOL */
      case 5: /* statement ::= function EOL */
      case 6: /* statement ::= EOL */
      case 32: /* block ::= element EOL */
      case 33: /* block ::= block element EOL */
#line 61 "grammar.y"
{
  yy_destructor(1,&yymsp[0].minor);
}
#line 759 "grammar.c"
        break;
      case 7: /* constant ::= IDENT EQ expr */
#line 66 "grammar.y"
{
         Module_create_constant(state, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); free(yymsp[-2].minor.yy0);
      yy_destructor(3,&yymsp[-1].minor);
}
#line 767 "grammar.c"
        break;
      case 8: /* parameters ::= LPAREN args RPAREN */
#line 70 "grammar.y"
{ yygotominor.yy7 = yymsp[-1].minor.yy7;   yy_destructor(4,&yymsp[-2].minor);
  yy_destructor(5,&yymsp[0].minor);
}
#line 774 "grammar.c"
        break;
      case 9: /* parameters ::= */
      case 12: /* args ::= */
#line 71 "grammar.y"
{ yygotominor.yy7 = calloc(1,sizeof(Parameters)); }
#line 780 "grammar.c"
        break;
      case 10: /* args ::= args COMMA expr */
#line 73 "grammar.y"
{ yymsp[-2].minor.yy7->args[yymsp[-2].minor.yy7->i++] = yymsp[0].minor.yy0; yygotominor.yy7=yymsp[-2].minor.yy7;   yy_destructor(6,&yymsp[-1].minor);
}
#line 786 "grammar.c"
        break;
      case 11: /* args ::= expr */
#line 74 "grammar.y"
{ yygotominor.yy7 = calloc(1,sizeof(Parameters)); yygotominor.yy7->args[yygotominor.yy7->i++] = yymsp[0].minor.yy0;}
#line 791 "grammar.c"
        break;
      case 13: /* operation ::= OP DOT TYPE parameters */
#line 78 "grammar.y"
{ Call_operation(state, state->current, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, yymsp[0].minor.yy7);   yy_destructor(8,&yymsp[-2].minor);
}
#line 797 "grammar.c"
        break;
      case 14: /* operation ::= OP parameters */
#line 81 "grammar.y"
{ Call_operation(state, state->current, yymsp[-1].minor.yy0, NULL, yymsp[0].minor.yy7); }
#line 802 "grammar.c"
        break;
      case 15: /* expr ::= HEX */
      case 16: /* expr ::= FLOAT */
      case 17: /* expr ::= INT */
      case 18: /* expr ::= STR */
      case 19: /* expr ::= CHR */
      case 20: /* expr ::= REG */
#line 83 "grammar.y"
{ yygotominor.yy0 = yymsp[0].minor.yy0; }
#line 812 "grammar.c"
        break;
      case 21: /* expr ::= IDENT */
#line 89 "grammar.y"
{ yygotominor.yy0 = Module_resolve_data(state, yymsp[0].minor.yy0); }
#line 817 "grammar.c"
        break;
      case 22: /* expr ::= function_reference */
#line 90 "grammar.y"
{ yygotominor.yy0 = yymsp[0].minor.yy52; }
#line 822 "grammar.c"
        break;
      case 23: /* expr ::= function_reference DOT IDENT */
#line 92 "grammar.y"
{ yygotominor.yy0 = Module_outside_function_data(state, yymsp[-2].minor.yy52, yymsp[0].minor.yy0);   yy_destructor(8,&yymsp[-1].minor);
}
#line 828 "grammar.c"
        break;
      case 24: /* expr ::= LABEL */
#line 95 "grammar.y"
{ yygotominor.yy0 = Label_expression(state->current, yymsp[0].minor.yy0); }
#line 833 "grammar.c"
        break;
      case 25: /* function_reference ::= IDENT DOT IDENT */
#line 99 "grammar.y"
{ yygotominor.yy52 = Module_resolve_function(state, yymsp[-2].minor.yy0, yymsp[0].minor.yy0);   yy_destructor(8,&yymsp[-1].minor);
}
#line 839 "grammar.c"
        break;
      case 26: /* directive ::= PERCENT IDENT parameters */
#line 102 "grammar.y"
{ Module_call_directive(state, yymsp[-1].minor.yy0, yymsp[0].minor.yy7);   yy_destructor(17,&yymsp[-2].minor);
}
#line 845 "grammar.c"
        break;
      case 27: /* function ::= FUNCTION function_decl block END */
#line 105 "grammar.y"
{ yygotominor.yy9 = Function_finalize(state, yymsp[-2].minor.yy9, yymsp[0].minor.yy0);   yy_destructor(18,&yymsp[-3].minor);
}
#line 851 "grammar.c"
        break;
      case 28: /* function_decl ::= IDENT LPAREN function_params RPAREN COLON TYPE */
#line 108 "grammar.y"
{
            yygotominor.yy9 = Function_create(state, yymsp[0].minor.yy0->value, yymsp[-5].minor.yy0->start, yymsp[-5].minor.yy0->len, yymsp[-3].minor.yy14); 
            free(yymsp[-5].minor.yy0); free(yymsp[0].minor.yy0);
          yy_destructor(4,&yymsp[-4].minor);
  yy_destructor(5,&yymsp[-2].minor);
  yy_destructor(20,&yymsp[-1].minor);
}
#line 862 "grammar.c"
        break;
      case 29: /* function_params ::= IDENT COLON TYPE */
#line 114 "grammar.y"
{ yygotominor.yy14 = FunctionParam_create(NULL, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); free(yymsp[-2].minor.yy0); free(yymsp[0].minor.yy0);   yy_destructor(20,&yymsp[-1].minor);
}
#line 868 "grammar.c"
        break;
      case 30: /* function_params ::= function_params COMMA IDENT COLON TYPE */
#line 117 "grammar.y"
{
                    yygotominor.yy14 = FunctionParam_create(yymsp[-4].minor.yy14, yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
                    free(yymsp[-2].minor.yy0);  // these have to be here or double free
                    free(yymsp[0].minor.yy0);
                  yy_destructor(6,&yymsp[-3].minor);
  yy_destructor(20,&yymsp[-1].minor);
}
#line 879 "grammar.c"
        break;
      case 31: /* function_params ::= */
#line 122 "grammar.y"
{ yygotominor.yy14 = NULL; }
#line 884 "grammar.c"
        break;
      case 36: /* element ::= LABEL */
#line 129 "grammar.y"
{ Label_statement(state->current, yymsp[0].minor.yy0); free(yymsp[0].minor.yy0); }
#line 889 "grammar.c"
        break;
      case 37: /* element ::= IDENT EQ expr */
#line 130 "grammar.y"
{
         Module_create_function_constant(state, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); free(yymsp[-2].minor.yy0);
        yy_destructor(3,&yymsp[-1].minor);
}
#line 897 "grammar.c"
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto);
  if( yyact < YYNSTATE ){
#ifdef NDEBUG
    /* If we are not debugging and the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = yyact;
      yymsp->major = yygoto;
      yymsp->minor = yygotominor;
    }else
#endif
    {
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YYNSTATE + YYNRULE + 1 );
    yy_accept(yypParser);
  }
}