void ClassStatement::outputCPPClassDecl(CodeGenerator &cg, AnalysisResultPtr ar, const char *clsName, const char *originalName, const char *parent) { ClassScopeRawPtr classScope = getClassScope(); VariableTablePtr variables = classScope->getVariables(); ConstantTablePtr constants = classScope->getConstants(); if (variables->hasAllJumpTables() && constants->hasJumpTable() && classScope->hasAllJumpTables()) { cg_printf("DECLARE_CLASS(%s, %s, %s)\n", clsName, originalName, parent); return; } // Now we start to break down DECLARE_CLASS into lines of code that could // be generated differently... cg_printf("DECLARE_CLASS_COMMON(%s, %s)\n", clsName, originalName); cg_printf("DECLARE_INVOKE_EX%s(%s, %s, %s)\n", Option::UseMethodIndex ? "WITH_INDEX" : "", clsName, originalName, parent); cg.printSection("DECLARE_STATIC_PROP_OPS"); cg_printf("public:\n"); if (classScope->needStaticInitializer()) { cg_printf("static void os_static_initializer();\n"); } if (variables->hasJumpTable(VariableTable::JumpTableClassStaticGetInit)) { cg_printf("static Variant os_getInit(CStrRef s);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_GETINIT_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassStaticGet)) { cg_printf("static Variant os_get(CStrRef s);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_GET_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassStaticLval)) { cg_printf("static Variant &os_lval(CStrRef s);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_LVAL_%s 1\n", clsName); } if (constants->hasJumpTable()) { cg_printf("static Variant os_constant(const char *s);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_CONSTANT_%s 1\n", clsName); } cg.printSection("DECLARE_INSTANCE_PROP_OPS"); cg_printf("public:\n"); if (variables->hasJumpTable(VariableTable::JumpTableClassGetArray)) { cg_printf("virtual void o_getArray(Array &props) const;\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_GETARRAY_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassSetArray)) { cg_printf("virtual void o_setArray(CArrRef props);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_SETARRAY_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassRealProp)) { cg_printf("virtual Variant *o_realProp(CStrRef s, int flags,\n"); cg_printf(" CStrRef context = null_string) " "const;\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_realProp_%s 1\n", clsName); } if (variables->hasNonStaticPrivate()) { cg_printf("Variant *o_realPropPrivate(CStrRef s, int flags) const;\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_realProp_PRIVATE_%s 1\n", clsName); } cg.printSection("DECLARE_INSTANCE_PUBLIC_PROP_OPS"); cg_printf("public:\n"); if (variables->hasJumpTable(VariableTable::JumpTableClassRealPropPublic)) { cg_printf("virtual Variant *o_realPropPublic(CStrRef s, " "int flags) const;\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_realProp_PUBLIC_%s 1\n", clsName); } cg.printSection("DECLARE_COMMON_INVOKE"); cg.printf("static bool os_get_call_info(MethodCallPackage &mcp, " "int64 hash = -1);\n"); if (Option::UseMethodIndex) { cg.printf("virtual bool o_get_call_info_with_index(MethodCallPackage &mcp," " MethodIndex mi, int64 hash = -1);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_INVOKE_%s 1\n", clsName); } if (classScope->hasJumpTable(ClassScope::JumpTableInvoke)) { cg.printf("virtual bool o_get_call_info(MethodCallPackage &mcp, " "int64 hash = -1);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_INVOKE_%s 1\n", clsName); } cg_printf("\n"); cg_printf("public:\n"); }
void ClassStatement::outputCPPClassDecl(CodeGenerator &cg, AnalysisResultPtr ar, const char *clsName, const char *originalName, const char *parent) { ClassScopePtr classScope = m_classScope.lock(); VariableTablePtr variables = classScope->getVariables(); ConstantTablePtr constants = classScope->getConstants(); if (variables->hasAllJumpTables() && constants->hasJumpTable() && classScope->hasAllJumpTables()) { cg_printf("DECLARE_CLASS(%s, %s, %s)\n", clsName, originalName, parent); return; } // Now we start to break down DECLARE_CLASS into lines of code that could // be generated differently... cg_printf("DECLARE_CLASS_COMMON(%s, %s)\n", clsName, originalName); cg_printf("DECLARE_INVOKE_EX(%s, %s, %s)\n", clsName, originalName, parent); cg.printSection("DECLARE_STATIC_PROP_OPS"); cg_printf("public:\n"); if (classScope->needStaticInitializer()) { cg_printf("static void os_static_initializer();\n"); } if (variables->hasJumpTable(VariableTable::JumpTableClassStaticGetInit)) { cg_printf("static Variant os_getInit(const char *s, int64 hash);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_GETINIT_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassStaticGet)) { cg_printf("static Variant os_get(const char *s, int64 hash);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_GET_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassStaticLval)) { cg_printf("static Variant &os_lval(const char *s, int64 hash);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_LVAL_%s 1\n", clsName); } if (constants->hasJumpTable()) { cg_printf("static Variant os_constant(const char *s);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_CONSTANT_%s 1\n", clsName); } cg.printSection("DECLARE_INSTANCE_PROP_OPS"); cg_printf("public:\n"); cg_printf("virtual bool o_exists(CStrRef s, int64 hash,\n"); cg_printf(" const char *context = NULL) const;\n"); cg_printf("bool o_existsPrivate(CStrRef s, int64 hash) const;\n"); cg_printf("virtual void o_get(Array &props) const;\n"); cg_printf("virtual Variant o_get(CStrRef s, int64 hash, " "bool error = true,\n"); cg_printf(" const char *context = NULL);\n"); cg_printf("Variant o_getPrivate(CStrRef s, int64 hash, " "bool error = true);\n"); cg_printf("virtual Variant o_set(CStrRef s, int64 hash, CVarRef v,\n"); cg_printf(" bool forInit = false,\n"); cg_printf(" const char *context = NULL);\n"); cg_printf("Variant o_setPrivate(CStrRef s, int64 hash, CVarRef v, " "bool forInit);\n"); cg_printf("virtual Variant &o_lval(CStrRef s, int64 hash,\n"); cg_printf(" const char *context = NULL);\n"); cg_printf("Variant &o_lvalPrivate(CStrRef s, int64 hash);\n"); cg.printSection("DECLARE_INSTANCE_PUBLIC_PROP_OPS"); cg_printf("public:\n"); if (variables->hasJumpTable(VariableTable::JumpTableClassExistsPublic)) { cg_printf("virtual bool o_existsPublic(CStrRef s, int64 hash) const;\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_exists_PUBLIC_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassGetPublic)) { cg_printf("virtual Variant o_getPublic(CStrRef s, int64 hash,\n"); cg_printf(" bool error = true);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_get_PUBLIC_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassSetPublic)) { cg_printf("virtual Variant o_setPublic(CStrRef s, int64 hash,\n"); cg_printf(" CVarRef v, bool forInit);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_set_PUBLIC_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassLvalPublic)) { cg_printf("virtual Variant &o_lvalPublic(CStrRef s, int64 hash);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_lval_PUBLIC_%s 1\n", clsName); } cg.printSection("DECLARE_COMMON_INVOKE"); if (classScope->hasJumpTable(ClassScope::JumpTableStaticInvoke)) { cg_printf("static Variant os_invoke(const char *c, const char *s,\n"); cg_printf(" CArrRef ps, int64 h, " "bool f = true);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_INVOKE_%s 1\n", clsName); } if (classScope->hasJumpTable(ClassScope::JumpTableInvoke)) { cg_printf("virtual Variant o_invoke(const char *s, CArrRef ps, " "int64 h,\n"); cg_printf(" bool f = true);\n"); cg_printf("virtual Variant o_invoke_few_args(const char *s, int64 h,\n"); cg_printf(" int count,\n"); cg_printf(" " "INVOKE_FEW_ARGS_DECL_ARGS);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_INVOKE_%s 1\n", clsName); } cg_printf("\n"); cg_printf("public:\n"); }
void ClassStatement::outputCPPClassDecl(CodeGenerator &cg, AnalysisResultPtr ar, const char *clsName, const char *originalName, const char *parent) { ClassScopePtr classScope = m_classScope.lock(); VariableTablePtr variables = classScope->getVariables(); ConstantTablePtr constants = classScope->getConstants(); if (variables->hasAllJumpTables() && constants->hasJumpTable() && classScope->hasAllJumpTables()) { cg_printf("DECLARE_CLASS(%s, %s, %s)\n", clsName, originalName, parent); return; } // Now we start to break down DECLARE_CLASS into lines of code that could // be generated differently... cg_printf("DECLARE_CLASS_COMMON(%s, %s)\n", clsName, originalName); cg_printf("DECLARE_INVOKE_EX(%s, %s, %s)\n", clsName, originalName, parent); cg.printSection("DECLARE_STATIC_PROP_OPS"); cg_printf("public:\n"); if (classScope->needStaticInitializer()) { cg_printf("static void os_static_initializer();\n"); } if (variables->hasJumpTable(VariableTable::JumpTableClassStaticGetInit)) { cg_printf("static Variant os_getInit(CStrRef s);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_GETINIT_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassStaticGet)) { cg_printf("static Variant os_get(CStrRef s);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_GET_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassStaticLval)) { cg_printf("static Variant &os_lval(CStrRef s);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_LVAL_%s 1\n", clsName); } if (constants->hasJumpTable()) { cg_printf("static Variant os_constant(const char *s);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_CONSTANT_%s 1\n", clsName); } cg.printSection("DECLARE_INSTANCE_PROP_OPS"); cg_printf("public:\n"); if (variables->hasJumpTable(VariableTable::JumpTableClassGetArray)) { cg_printf("virtual void o_getArray(Array &props) const;\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_GETARRAY_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassSetArray)) { cg_printf("virtual void o_setArray(CArrRef props);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_SETARRAY_%s 1\n", clsName); } if (variables->hasJumpTable(VariableTable::JumpTableClassRealProp)) { cg_printf("virtual Variant *o_realProp(CStrRef s, int flags,\n"); cg_printf(" CStrRef context = null_string) " "const;\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_realProp_%s 1\n", clsName); } if (variables->hasNonStaticPrivate()) { cg_printf("Variant *o_realPropPrivate(CStrRef s, int flags) const;\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_realProp_PRIVATE_%s 1\n", clsName); } cg.printSection("DECLARE_INSTANCE_PUBLIC_PROP_OPS"); cg_printf("public:\n"); if (variables->hasJumpTable(VariableTable::JumpTableClassRealPropPublic)) { cg_printf("virtual Variant *o_realPropPublic(CStrRef s, " "int flags) const;\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_realProp_PUBLIC_%s 1\n", clsName); } cg.printSection("DECLARE_COMMON_INVOKE"); if (classScope->hasJumpTable(ClassScope::JumpTableStaticInvoke)) { cg_printf("static Variant os_invoke(const char *c, " "MethodIndex methodIndex,\n"); cg_printf(" const char *s, CArrRef ps, int64 h, " "bool f = true);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_STATIC_INVOKE_%s 1\n", clsName); } if (classScope->hasJumpTable(ClassScope::JumpTableInvoke)) { cg_printf("virtual Variant o_invoke(MethodIndex methodIndex, " "const char *s, CArrRef ps,\n"); cg_printf(" int64 h, bool f = true);\n"); cg_printf("virtual Variant o_invoke_few_args(MethodIndex methodIndex, " "const char *s,\n"); cg_printf(" int64 h, int count,\n"); cg_printf(" " "INVOKE_FEW_ARGS_DECL_ARGS);\n"); } else { cg_printf("#define OMIT_JUMP_TABLE_CLASS_INVOKE_%s 1\n", clsName); } cg_printf("\n"); cg_printf("public:\n"); }