diff --git a/src/.gitignore b/src/.gitignore index 10a8f2ca32176324af2cbbadd76d8c8d9e7b832f..3abefea36abae36afc4daf1b6b8eba9e975aa22b 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -19,7 +19,6 @@ autom4te.cache /conftest.h /dependencies /dumpmodule.log -/facetgroup.c /hilfe /hsort_template.h /interpret_functions_fixed.h diff --git a/src/Makefile.in b/src/Makefile.in index 7b8bbb30b18a3dc55dd972deb0a2305741abbdb3..0af161026b13aeba6783a829cef49a89aa308c95 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -184,7 +184,6 @@ CORE_OBJ= \ queue.o \ builtin.o \ iterators.o \ - facetgroup.o \ svalue.o \ las.o \ builtin_functions.o \ @@ -1285,8 +1284,6 @@ builtin.o: $(SRCDIR)/builtin.c $(SRCDIR)/whitespace.h iterators.o: $(SRCDIR)/iterators.c -facetgroup.o: $(SRCDIR)/facetgroup.c - backend.o: $(SRCDIR)/backend.c libpike.o: $(SRCDIR)/libpike.c @@ -1454,7 +1451,6 @@ HFILES= \ version.protos \ builtin.protos \ iterators.protos \ - facetgroup.protos \ rbtree.protos $(HFILES): precompile.sh-stamp diff --git a/src/acconfig.h b/src/acconfig.h index 00f35148b0c07e6d902e2226381e1f8ef3965a27..b2d63be008d4b50bbc1dbf3b1dd252d098771440 100644 --- a/src/acconfig.h +++ b/src/acconfig.h @@ -73,9 +73,6 @@ /* Define this to enable the internal Pike security system */ #undef PIKE_SECURITY -/* Define this to enable experimental facets support */ -#undef WITH_FACETS - /* Define this to enable the internal bignum conversion */ #undef AUTO_BIGNUM diff --git a/src/configure.in b/src/configure.in index 5dfdf75a43014cbd8f00e516104b020063f1c736..b7ffae429358af09b0588dc9c14a39a8f47c617c 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1748,10 +1748,6 @@ MY_AC_ARG_WITH(lock, [enable experimental code for multicpu machines (EXPERIMENTAL).]), [],[AC_DEFINE(PIKE_RUN_UNLOCKED)]) -AC_ARG_WITH(facets, MY_DESCR([--with-facets], - [enable experimental facet support (EXPERIMENTAL).]), - [AC_DEFINE(WITH_FACETS)]) - AC_ARG_WITH(pike-type, MY_DESCR([--without-pike-type], [disable struct pike_type (IGNORED).])) diff --git a/src/facetgroup.cmod b/src/facetgroup.cmod deleted file mode 100644 index eed03edc96c6613462e2ab56184306bbf5935008..0000000000000000000000000000000000000000 --- a/src/facetgroup.cmod +++ /dev/null @@ -1,297 +0,0 @@ -/* -*- c -*- -|| This file is part of Pike. For copyright information see COPYRIGHT. -|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING -|| for more information. -*/ - -#include "global.h" -#include "fdlib.h" -#include "main.h" -#include "object.h" -#include "mapping.h" -#include "multiset.h" -#include "svalue.h" -#include "stralloc.h" -#include "array.h" -#include "pike_macros.h" -#include "pike_error.h" -#include "pike_memory.h" -#include "dynamic_buffer.h" -#include "interpret.h" -#include "las.h" -#include "gc.h" -#include "stralloc.h" -#include "opcodes.h" -#include "pike_error.h" -#include "program.h" -#include "operators.h" -#include "builtin_functions.h" -#include "constants.h" -#include "program.h" -#include "block_alloc.h" - -DECLARATIONS - -#ifdef WITH_FACETS - -/*! @class FacetGroup - *! - *! This class is used to handle facets in the system. All facets - *! in the system have to belong to a facet group. A facet - *! group is a pike module that inherits from this class. For - *! example you can create a file MyFacetgroup.pmod with the following - *! content: - *! - *! @code - *! inherit FacetGroup; - *! @endcode - *! - *! You can then use the facet group MyFacetGroup in a facet-class - *! like this: - *! - *! @code - *! class A - *! { - *! facet NameOfMyFacet : .MyFacetGroup; - *! // Rest of class A - *! } - *! @endcode - *! - */ - -/* Linked list of facet-classes */ -struct facet_class_struct { - int id; - struct facet_class_struct *next; -}; - -/* Linked list of facets with their facet-classes */ -struct facet_node_struct { - struct pike_string *name; - struct facet_class_struct *classes; - struct facet_node_struct *next; -}; - -/* Linked list of facets a product class is inheriting from */ -struct facet_list_struct { - int facet_index; - int facet_class; - struct facet_list_struct *next; -}; - -/* Linked list of product classes with lists of what facets they use */ -struct product_class_struct { - int id; - struct facet_list_struct *facets; - int num_used_facets; - struct product_class_struct *next; -}; - -BLOCK_ALLOC_FILL_PAGES(facet_class_struct, 2) -BLOCK_ALLOC_FILL_PAGES(facet_node_struct, 2) -BLOCK_ALLOC_FILL_PAGES(product_class_struct, 2) -BLOCK_ALLOC_FILL_PAGES(facet_list_struct, 2) - -/* The actual facet_group class */ -PIKECLASS facet_group -{ - CVAR struct facet_node_struct *facets; - CVAR struct product_class_struct *pclasses; - CVAR int num_facets; - CVAR int checked_product_classes; - - /* Retruns 1 if product classes in this facet group have been checked, - * 0 otherwise */ - PIKEFUN int product_classes_checked() { - RETURN THIS->checked_product_classes; - } - - /* Function to check that all product-classes inherits from all facet */ - PIKEFUN void check_product_classes() { - struct facet_list_struct *fl; - struct product_class_struct *pc; - int error = 0; - for(pc=THIS->pclasses; pc; pc = pc->next) { - if (pc->num_used_facets < THIS->num_facets) { - my_yyerror("Product class only inherits from %d out of %d facets.", - pc->num_used_facets, THIS->num_facets); - } -#ifdef PIKE_DEBUG - else if (pc->num_used_facets > THIS->num_facets) { - /* It should be impossible to get here */ - yyerror("Product class inherits more than once from some facet."); - } -#endif - } - THIS->checked_product_classes = 1; - pop_n_elems(args); - } - - /* Add info that the class "class" inherits from the facet "facet_index" */ - PIKEFUN void add_product_class(int class, int facet_index, int facet_class) { - struct facet_list_struct *fl, *fltmp; - struct product_class_struct *pc, *pctmp; - - /* Set checked_product_classes to 0 to indicate that not all - * product classes have been checked */ - THIS->checked_product_classes = 0; - - /* Check whether the product class is allready in our list of - * product classes */ - for (pc=THIS->pclasses; pc; pc = pc->next) { - if (class == pc->id) - break; - } - - if (!pc) { /* New product class */ - pctmp = alloc_product_class_struct(); - pctmp->id = class; - pctmp->facets = NULL; - pctmp->num_used_facets = 0; - pctmp->next = THIS->pclasses; - THIS->pclasses = pctmp; - pc = pctmp; - } - - /* pc now points to the product class to modify */ - for(fl=pc->facets; fl; fl = fl->next) { - if (fl->facet_index == facet_index) - break; - } - if (!fl) { - //Add facet "facet_index" to product class "class"'s inherits - fltmp = alloc_facet_list_struct(); - fltmp->facet_index = facet_index; - fltmp->facet_class = facet_class; - pc->num_used_facets++; - fltmp->next = pc->facets; - pc->facets = fltmp; - } - else /* The product class already inherits from this facet */ - if (fl->facet_class != facet_class) - yyerror("Product class can only inherit from one class in every facet."); - pop_n_elems(args); - } - - /* Add a facet class in the facet group */ - PIKEFUN int add_facet_class(string facet, int class, int product_class) { - struct facet_class_struct *c, *ctmp; - struct facet_node_struct *f, *prevf, *ftmp; - struct product_class_struct *pc, *prevpc; - struct object *o; - int facet_index = 0; - - // Check if it is a new facet or not. - prevf = NULL; - for(f=THIS->facets; f; f=f->next, facet_index++) { - if ( is_same_string(f->name,facet) ) - break; - prevf=f; - } - - if (product_class) { - // This occurs if the inherit statement comes before the facet - // statement in the class - for (prevpc=pc=THIS->pclasses; pc; pc = pc->next) { - if (pc->id == class) - break; - prevpc = pc; - } - if (!pc) - yyerror("Program marked as product class but not found in list of product classes."); - else { - if (pc->num_used_facets > 1 || - facet_index != pc->facets->facet_index) - yyerror("Facet class can not inherit from a class in another facet."); - else { - if (prevpc->id == pc->id) - THIS->pclasses = pc->next; - else - prevpc->next = pc->next; - really_free_product_class_struct(pc); - } - } - } - - if (!f) { /* A new facet */ - THIS->num_facets++; - f = alloc_facet_node_struct(); - add_ref(f->name = facet); - f->next = NULL; - if (!prevf) - THIS->facets = f; - else - prevf->next = f; - f->classes = NULL; - } - - // f now points to the facet 'facet' in 'facets' - // Check whether the class 'class' is already in the facet - for (c=f->classes; c; c = c->next) { - if (class == c->id) - break; - } - - if (c) - yyerror("Redundant facet statement."); - else { - ctmp = alloc_facet_class_struct(); - ctmp->id = class; - ctmp->next = f->classes; - f->classes = ctmp; - } - - RETURN facet_index; - } - - INIT { - THIS->facets = NULL; - THIS->pclasses = NULL; - THIS->num_facets = 0; - THIS->checked_product_classes = 0; - } - - EXIT { - struct facet_node_struct *f, *fnext; - struct facet_class_struct *fc, *fcnext; - struct product_class_struct *p, *pnext; - struct facet_list_struct *fl, *flnext; - for (fnext=f=THIS->facets; fnext; f=fnext) { - fnext = f->next; - for (fcnext=fc=f->classes; fcnext; fc=fcnext) { - fcnext = fc->next; - really_free_facet_class_struct(fc); - } - free_string(f->name); - really_free_facet_node_struct(f); - } - for (pnext=p=THIS->pclasses; pnext; p=pnext) { - pnext = p->next; - for (flnext=fl=p->facets; flnext; fl=flnext) { - flnext = fl->next; - really_free_facet_list_struct(fl); - } - really_free_product_class_struct(p); - } - } -}; - -void init_facetgroup(void) -{ - init_facet_class_struct_blocks(); - init_facet_node_struct_blocks(); - init_facet_list_struct_blocks(); - init_product_class_struct_blocks(); - INIT; - add_global_program("FacetGroup", facet_group_program); -} - -void exit_facetgroup(void) -{ - EXIT -} - -/*! @endclass - */ - -#endif diff --git a/src/language.yacc b/src/language.yacc index 21628c46928cf52dc89ed4f4da23d09510aa10e7..72b1149dc5d8256f1aa3fe86ecdfa47ae95b3f05 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -62,7 +62,6 @@ %token TOK_IF %token TOK_IMPORT %token TOK_INHERIT -%token TOK_FACET %token TOK_INLINE %token TOK_LOCAL_ID %token TOK_FINAL_ID @@ -221,7 +220,6 @@ int yylex(YYSTYPE *yylval); %type <number> TOK_DEFAULT %type <number> TOK_DO %type <number> TOK_ELSE -%type <number> TOK_FACET %type <number> TOK_FLOAT_ID %type <number> TOK_FOR %type <number> TOK_FOREACH @@ -465,47 +463,6 @@ program_ref: low_program_ref } ; -facet: TOK_FACET TOK_IDENTIFIER ':' idents ';' - { -#ifdef WITH_FACETS - struct object *o; - if (Pike_compiler->compiler_pass == 1) { - if (Pike_compiler->new_program->flags & PROGRAM_IS_FACET) { - yyerror("A class can only belong to one facet."); - } - else { - resolv_constant($4); - if (TYPEOF(Pike_sp[-1]) == T_OBJECT) { - /* FIXME: Object subtypes! */ - o = Pike_sp[-1].u.object; - ref_push_string($2->u.sval.u.string); - push_int(Pike_compiler->new_program->id); - push_int(!!(Pike_compiler->new_program->flags & PROGRAM_IS_PRODUCT)); - safe_apply(o, "add_facet_class", 3); - if (TYPEOF(Pike_sp[-1]) == T_INT && - Pike_sp[-1].u.integer >= 0) { - Pike_compiler->new_program->flags &= ~PROGRAM_IS_PRODUCT; - Pike_compiler->new_program->flags |= PROGRAM_IS_FACET; - Pike_compiler->new_program->facet_index = Pike_sp[-1].u.integer; - add_ref(Pike_compiler->new_program->facet_group = o); - } - else - yyerror("Could not add facet class to system."); - pop_stack(); - } - else - yyerror("Invalid facet group specifier."); - pop_stack(); - } - } - free_node($2); - free_node($4); -#else - yyerror("No support for facets."); -#endif - } - ; - inherit_ref: { SET_FORCE_RESOLVE($<number>$); @@ -528,28 +485,6 @@ inheritance: modifiers TOK_INHERIT inherit_ref optional_rename_inherit ';' if($4) s=$4->u.sval.u.string; compiler_do_inherit($3,$1,s); } - -#ifdef WITH_FACETS - /* If this is a product class, check that all product classes in its - * facet-group inherit from all facets */ - if($3 && Pike_compiler->compiler_pass == 2) { - if (Pike_compiler->new_program->flags & PROGRAM_IS_PRODUCT) { - if (!Pike_compiler->new_program->facet_group) - yyerror("Product class without facet group."); - else { - safe_apply(Pike_compiler->new_program->facet_group, - "product_classes_checked", 0); - if (TYPEOF(Pike_sp[-1]) == T_INT && - Pike_sp[-1].u.integer == 0) { - pop_stack(); - safe_apply(Pike_compiler->new_program->facet_group, - "check_product_classes", 0); - } - pop_stack(); - } - } - } -#endif if($4) free_node($4); pop_stack(); if ($3) free_node($3); @@ -1068,7 +1003,6 @@ def: modifiers optional_attributes type_or_error optional_constant optional_star } } | inheritance {} - | facet {} | import {} | constant {} | modifiers class { free_node($2); } @@ -1238,7 +1172,6 @@ magic_identifiers3: | TOK_CONSTANT { $$ = "constant"; } | TOK_CONTINUE { $$ = "continue"; } | TOK_DEFAULT { $$ = "default"; } - | TOK_FACET { $$ = "facet"; } | TOK_IMPORT { $$ = "import"; } | TOK_INHERIT { $$ = "inherit"; } | TOK_LAMBDA { $$ = "lambda"; } @@ -4570,8 +4503,6 @@ bad_expr_ident: { yyerror_reserved("return"); } | TOK_IMPORT { yyerror_reserved("import"); } - | TOK_FACET - { yyerror_reserved("facet"); } | TOK_INHERIT { yyerror_reserved("inherit"); } | TOK_CATCH diff --git a/src/lexer.h b/src/lexer.h index 0c30962e3d195c1460c96d369f4a702281903022..155d65febdd5692dc343a3daf18aed71f03197aa 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -497,12 +497,6 @@ static int low_yylex(struct lex *lex, YYSTYPE *yylval) case TWO_CHAR('e','x'): if(ISWORD("extern")) return TOK_EXTERN; break; -#ifdef WITH_FACETS -#warning "facet" keyword needs compat if enabled by default - case TWO_CHAR('f','a'): - if(ISWORD("facet")) return TOK_FACET; - break; -#endif case TWO_CHAR('f','i'): if(ISWORD("final")) return TOK_FINAL_ID; break; diff --git a/src/module.c b/src/module.c index 4036ca023c75e418dd87809fbc0b5fbba2fbd7c3..ec2105b1fab167ebba4f288b9a3fd8480a5a86d1 100644 --- a/src/module.c +++ b/src/module.c @@ -53,9 +53,6 @@ static void init_builtin_modules(void) { void init_iterators(void); -#ifdef WITH_FACETS - void init_facetgroup(void); -#endif #ifdef DEBUG_MALLOC /* Make some statically allocated structs known to dmalloc. These @@ -118,12 +115,6 @@ static void init_builtin_modules(void) TRACE((stderr, "Init dynamic loading...\n")); init_dynamic_load(); -#ifdef WITH_FACETS - - TRACE((stderr, "Init facets...\n")); - - init_facetgroup(); -#endif TRACE((stderr, "Init sprintf...\n")); @@ -134,9 +125,6 @@ static void exit_builtin_modules(void) { #ifdef DO_PIKE_CLEANUP void exit_iterators(void); -#ifdef WITH_FACETS - void exit_facetgroup(void); -#endif /* Clear various global references. */ @@ -155,9 +143,6 @@ static void exit_builtin_modules(void) cleanup_module_support(); exit_operators(); exit_iterators(); -#ifdef WITH_FACETS - exit_facetgroup(); -#endif cleanup_program(); cleanup_compiler(); cleanup_error(); diff --git a/src/program.c b/src/program.c index 86960447d1d50a5a151933371d4984ca24fbded9..5739fa93b473b2225a56f83b7093710d5642c786 100644 --- a/src/program.c +++ b/src/program.c @@ -2748,13 +2748,6 @@ void low_start_new_program(struct program *p, CHECK_COMPILER(); -#ifdef WITH_FACETS - if(Pike_compiler->compiler_pass == 1 && p) { - p->facet_index = -1; - p->facet_group = NULL; - } -#endif - /* We don't want to change thread, but we don't want to * wait for the other threads to complete either. */ @@ -3124,13 +3117,6 @@ static void exit_program_struct(struct program *p) DOUBLEUNLINK(first_program, p); -#ifdef WITH_FACETS - if(p->facet_group) - { - free_object(p->facet_group); - } -#endif - if(p->flags & PROGRAM_OPTIMIZED) { #ifdef PIKE_USE_MACHINE_CODE @@ -4536,55 +4522,6 @@ static int find_depth(struct program_state *state, } #endif -#ifdef WITH_FACETS -void check_for_facet_inherit(struct program *p) -{ - /* If the inherit statement comes before the facet keyword in the - * class declaration the class will be temporarily marked as a - * product-class, but this will be taken care of when the facet - * keyword is found. */ - if (!p) return; - if (Pike_compiler->new_program->facet_group && - p->facet_group != Pike_compiler->new_program->facet_group) - yyerror("A class can not belong to two facet-groups."); - if (p->flags & PROGRAM_IS_FACET) { - if (Pike_compiler->new_program->flags & PROGRAM_IS_FACET) { - if(Pike_compiler->new_program->facet_index != p->facet_index) - yyerror("Facet class can't inherit from class in different facet."); - } - /* Otherwise this is a product class */ - else { - if( !Pike_compiler->new_program->facet_group ) { - Pike_compiler->new_program->flags |= PROGRAM_IS_PRODUCT; - add_ref(p->facet_group); - Pike_compiler->new_program->facet_group = p->facet_group; - } - push_int(Pike_compiler->new_program->id); - push_int(p->facet_index); - push_int(p->id); - safe_apply(p->facet_group, "add_product_class", 3); - pop_stack(); - } - } - /* The inherited class is not a facet class */ - else if (p->flags & PROGRAM_IS_PRODUCT) { - if (Pike_compiler->new_program->flags & PROGRAM_IS_FACET) { - yyerror("Facet class can't inherit from product class."); - } - else if(Pike_compiler->new_program->flags & PROGRAM_IS_PRODUCT){ - yyerror("Product class can't inherit from other product class."); - } - /* A class that inherits from a product class is also a product class */ - else { - Pike_compiler->new_program->flags |= PROGRAM_IS_PRODUCT; - add_ref(p->facet_group); - Pike_compiler->new_program->facet_group = p->facet_group; - } - } -} -#endif - - static void lower_inherit(struct program *p, struct object *parent, int parent_identifier, @@ -4672,11 +4609,6 @@ static void lower_inherit(struct program *p, return; } -#ifdef WITH_FACETS - /* Check if inherit is a facet inherit. */ - check_for_facet_inherit(p); -#endif - if (p == placeholder_program) { yyerror("Trying to inherit placeholder program (resolver problem)."); return; diff --git a/src/program.h b/src/program.h index a9d32fc86704e82a3eae57adc2119a0a6de97bcd..f2f46607ca3d5f38c21ca5525c59de753dcc17f5 100644 --- a/src/program.h +++ b/src/program.h @@ -565,10 +565,6 @@ struct pike_trampoline * module. */ #define PROGRAM_LIVE_OBJ 0x2000 -/* Indicates that the class is a facet or product_class. */ -#define PROGRAM_IS_FACET 0x4000 -#define PROGRAM_IS_PRODUCT 0x8000 - /* Using define instead of enum allows for ifdefs - Hubbe */ #define PROG_EVENT_INIT 0 #define PROG_EVENT_EXIT 1 @@ -643,12 +639,6 @@ struct program #include "program_areas.h" INT16 lfuns[NUM_LFUNS]; - -#ifdef WITH_FACETS - /* Facet related stuff */ - INT32 facet_index; /* Index to the facet this facet class belongs to */ - struct object *facet_group; -#endif }; PMOD_EXPORT void dump_program_tables (const struct program *p, int indent);